Clover Coverage Report - EasyMock 3.0
Coverage timestamp: sam. mai 8 2010 14:37:27 CEST
37   97   10   7,4
0   70   0,27   5
5     2  
1    
 
  NameTest       Line # 29 37 0% 10 1 97,6% 0.97619045
 
  (10)
 
1    /**
2    * Copyright 2001-2010 the original author or authors.
3    *
4    * Licensed under the Apache License, Version 2.0 (the "License");
5    * you may not use this file except in compliance with the License.
6    * You may obtain a copy of the License at
7    *
8    * http://www.apache.org/licenses/LICENSE-2.0
9    *
10    * Unless required by applicable law or agreed to in writing, software
11    * distributed under the License is distributed on an "AS IS" BASIS,
12    * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13    * See the License for the specific language governing permissions and
14    * limitations under the License.
15    */
16   
17    package org.easymock.tests2;
18   
19    import static org.easymock.EasyMock.*;
20    import static org.junit.Assert.*;
21   
22    import org.easymock.IMocksControl;
23    import org.easymock.tests.IMethods;
24    import org.junit.Test;
25   
26    /**
27    * @author OFFIS, Tammo Freese
28    */
 
29    public class NameTest {
 
30  2 toggle @Test
31    public void nameForMock() {
32  2 final IMethods mock = createMock("mock", IMethods.class);
33  2 mock.simpleMethod();
34  2 replay(mock);
35  2 try {
36  2 verify(mock);
37    } catch (final AssertionError expected) {
38  2 final String actualMessage = expected.getMessage();
39  2 final String expectedMessage = "\n Expectation failure on verify:\n mock.simpleMethod(): expected: 1, actual: 0";
40  2 assertEquals(expectedMessage, actualMessage);
41    }
42    }
43   
 
44  2 toggle @Test
45    public void nameForStrictMock() {
46  2 final IMethods mock = createStrictMock("mock", IMethods.class);
47  2 mock.simpleMethod();
48  2 replay(mock);
49  2 try {
50  2 verify(mock);
51    } catch (final AssertionError expected) {
52  2 final String actualMessage = expected.getMessage();
53  2 final String expectedMessage = "\n Expectation failure on verify:\n mock.simpleMethod(): expected: 1, actual: 0";
54  2 assertEquals(expectedMessage, actualMessage);
55    }
56    }
57   
 
58  2 toggle @Test
59    public void nameForNiceMock() {
60  2 final IMethods mock = createNiceMock("mock", IMethods.class);
61  2 mock.simpleMethod();
62  2 replay(mock);
63  2 try {
64  2 verify(mock);
65    } catch (final AssertionError expected) {
66  2 final String actualMessage = expected.getMessage();
67  2 final String expectedMessage = "\n Expectation failure on verify:\n mock.simpleMethod(): expected: 1, actual: 0";
68  2 assertEquals(expectedMessage, actualMessage);
69    }
70    }
71   
 
72  2 toggle @Test
73    public void nameForMocksControl() {
74  2 final IMocksControl control = createControl();
75  2 final IMethods mock = control.createMock("mock", IMethods.class);
76  2 mock.simpleMethod();
77  2 replay(mock);
78  2 try {
79  2 verify(mock);
80    } catch (final AssertionError expected) {
81  2 final String actualMessage = expected.getMessage();
82  2 final String expectedMessage = "\n Expectation failure on verify:\n mock.simpleMethod(): expected: 1, actual: 0";
83  2 assertEquals(expectedMessage, actualMessage);
84    }
85    }
86   
 
87  2 toggle @Test
88    public void shouldThrowIllegalArgumentExceptionIfNameIsNoValidJavaIdentifier() {
89  2 try {
90  2 createMock("no-valid-java-identifier", IMethods.class);
91  0 throw new AssertionError();
92    } catch (final IllegalArgumentException expected) {
93  2 assertEquals("'no-valid-java-identifier' is not a valid Java identifier.", expected.getMessage());
94    }
95    }
96   
97    }