Clover Coverage Report - EasyMock 2.4
Coverage timestamp: mer. juil. 2 2008 02:17:38 CEST
96   302   47   4
0   269   0,49   24
24     1,96  
1    
 
 
  RecordStateMethodCallMissingTest       Line # 15 96 47 80,8% 0.80833334
 
  (23)
 
1    /*
2    * Copyright (c) 2001-2008 OFFIS, Tammo Freese.
3    * This program is made available under the terms of the MIT License.
4    */
5    package org.easymock.tests;
6   
7    import static org.easymock.EasyMock.*;
8    import static org.junit.Assert.*;
9   
10    import org.easymock.MockControl;
11    import org.junit.Before;
12    import org.junit.Test;
13   
14    @SuppressWarnings("deprecation")
 
15    public class RecordStateMethodCallMissingTest {
16    MockControl<IMethods> control;
17   
18    IMethods mock;
19   
 
20  23 toggle @Before
21    public void setup() {
22  23 control = MockControl.createControl(IMethods.class);
23  23 mock = control.getMock();
24    }
25   
 
26  1 toggle @Test
27    public void setBooleanReturnValueWithoutMethodCall() {
28  1 try {
29  1 control.setReturnValue(false);
30  0 fail("IllegalStateException expected");
31    } catch (IllegalStateException expected) {
32  1 assertEquals(
33    "method call on the mock needed before setting return value",
34    expected.getMessage());
35    }
36    }
37   
 
38  1 toggle @Test
39    public void setLongReturnValueWithoutMethodCall() {
40  1 try {
41  1 control.setReturnValue(0);
42  0 fail("IllegalStateException expected");
43    } catch (IllegalStateException expected) {
44  1 assertEquals(
45    "method call on the mock needed before setting return value",
46    expected.getMessage());
47    }
48    }
49   
 
50  1 toggle @Test
51    public void setFloatReturnValueWithoutMethodCall() {
52  1 try {
53  1 control.setReturnValue((float) 0.0);
54  0 fail("IllegalStateException expected");
55    } catch (IllegalStateException expected) {
56  1 assertEquals(
57    "method call on the mock needed before setting return value",
58    expected.getMessage());
59    }
60    }
61   
 
62  1 toggle @Test
63    public void setDoubleReturnValueWithoutMethodCall() {
64  1 try {
65  1 control.setReturnValue(0.0);
66  0 fail("IllegalStateException expected");
67    } catch (IllegalStateException expected) {
68  1 assertEquals(
69    "method call on the mock needed before setting return value",
70    expected.getMessage());
71    }
72    }
73   
 
74  1 toggle @Test
75    public void setObjectReturnValueWithoutMethodCall() {
76  1 try {
77  1 control.setReturnValue(null);
78  0 fail("IllegalStateException expected");
79    } catch (IllegalStateException expected) {
80  1 assertEquals(
81    "method call on the mock needed before setting return value",
82    expected.getMessage());
83    }
84    }
85   
 
86  1 toggle @Test
87    public void setVoidCallableWithoutMethodCall() {
88  1 try {
89  1 control.setVoidCallable();
90  0 fail("IllegalStateException expected");
91    } catch (IllegalStateException expected) {
92  1 assertEquals(
93    "method call on the mock needed before setting void callable",
94    expected.getMessage());
95    }
96    }
97   
 
98  1 toggle @Test
99    public void setThrowableWithoutMethodCall() {
100  1 try {
101  1 control.setThrowable(new RuntimeException());
102  0 fail("IllegalStateException expected");
103    } catch (IllegalStateException expected) {
104  1 assertEquals(
105    "method call on the mock needed before setting Throwable",
106    expected.getMessage());
107    }
108    }
109   
 
110  1 toggle @Test
111    public void setBooleanReturnValueCountWithoutMethodCall() {
112  1 try {
113  1 control.setReturnValue(false, 3);
114  0 fail("IllegalStateException expected");
115    } catch (IllegalStateException expected) {
116  1 assertEquals(
117    "method call on the mock needed before setting return value",
118    expected.getMessage());
119    }
120    }
121   
 
122  1 toggle @Test
123    public void setLongReturnValueCountWithoutMethodCall() {
124  1 try {
125  1 control.setReturnValue(0, 3);
126  0 fail("IllegalStateException expected");
127    } catch (IllegalStateException expected) {
128  1 assertEquals(
129    "method call on the mock needed before setting return value",
130    expected.getMessage());
131    }
132    }
133   
 
134  1 toggle @Test
135    public void setFloatReturnValueCountWithoutMethodCall() {
136  1 try {
137  1 control.setReturnValue((float) 0.0, 3);
138  0 fail("IllegalStateException expected");
139    } catch (IllegalStateException expected) {
140  1 assertEquals(
141    "method call on the mock needed before setting return value",
142    expected.getMessage());
143    }
144    }
145   
 
146  1 toggle @Test
147    public void setDoubleReturnValueCountWithoutMethodCall() {
148  1 try {
149  1 control.setReturnValue(0.0, 3);
150  0 fail("IllegalStateException expected");
151    } catch (IllegalStateException expected) {
152  1 assertEquals(
153    "method call on the mock needed before setting return value",
154    expected.getMessage());
155    }
156    }
157   
 
158  1 toggle @Test
159    public void setObjectReturnValueCountWithoutMethodCall() {
160  1 try {
161  1 control.setReturnValue(null, 3);
162  0 fail("IllegalStateException expected");
163    } catch (IllegalStateException expected) {
164  1 assertEquals(
165    "method call on the mock needed before setting return value",
166    expected.getMessage());
167    }
168    }
169   
 
170  1 toggle @Test
171    public void setVoidCallableCountWithoutMethodCall() {
172  1 try {
173  1 control.setVoidCallable(3);
174  0 fail("IllegalStateException expected");
175    } catch (IllegalStateException expected) {
176  1 assertEquals(
177    "method call on the mock needed before setting void callable",
178    expected.getMessage());
179    }
180    }
181   
 
182  1 toggle @Test
183    public void setThrowableCountWithoutMethodCall() {
184  1 try {
185  1 control.setThrowable(new RuntimeException(), 3);
186  0 fail("IllegalStateException expected");
187    } catch (IllegalStateException expected) {
188  1 assertEquals(
189    "method call on the mock needed before setting Throwable",
190    expected.getMessage());
191    }
192    }
193   
 
194  1 toggle @Test
195    public void setBooleanDefaultReturnValueWithoutMethodCall() {
196  1 try {
197  1 control.setDefaultReturnValue(false);
198  0 fail("IllegalStateException expected");
199    } catch (IllegalStateException expected) {
200  1 assertEquals(
201    "method call on the mock needed before setting default return value",
202    expected.getMessage());
203    }
204    }
205   
 
206  1 toggle @Test
207    public void setLongDefaultReturnValueWithoutMethodCall() {
208  1 try {
209  1 control.setDefaultReturnValue(0);
210  0 fail("IllegalStateException expected");
211    } catch (IllegalStateException expected) {
212  1 assertEquals(
213    "method call on the mock needed before setting default return value",
214    expected.getMessage());
215    }
216    }
217   
 
218  1 toggle @Test
219    public void setFloatDefaultReturnValueWithoutMethodCall() {
220  1 try {
221  1 control.setDefaultReturnValue((float) 0.0);
222  0 fail("IllegalStateException expected");
223    } catch (IllegalStateException expected) {
224  1 assertEquals(
225    "method call on the mock needed before setting default return value",
226    expected.getMessage());
227    }
228    }
229   
 
230  1 toggle @Test
231    public void setDoubleDefaultReturnValueWithoutMethodCall() {
232  1 try {
233  1 control.setDefaultReturnValue(0.0);
234  0 fail("IllegalStateException expected");
235    } catch (IllegalStateException expected) {
236  1 assertEquals(
237    "method call on the mock needed before setting default return value",
238    expected.getMessage());
239    }
240    }
241   
 
242  1 toggle @Test
243    public void setObjectDefaultReturnValueWithoutMethodCall() {
244  1 try {
245  1 control.setDefaultReturnValue(null);
246  0 fail("IllegalStateException expected");
247    } catch (IllegalStateException expected) {
248  1 assertEquals(
249    "method call on the mock needed before setting default return value",
250    expected.getMessage());
251    }
252    }
253   
 
254  1 toggle @Test
255    public void setDefaultVoidCallableWithoutMethodCall() {
256  1 try {
257  1 control.setDefaultVoidCallable();
258  0 fail("IllegalStateException expected");
259    } catch (IllegalStateException expected) {
260  1 assertEquals(
261    "method call on the mock needed before setting default void callable",
262    expected.getMessage());
263    }
264    }
265   
 
266  1 toggle @Test
267    public void setDefaultThrowableWithoutMethodCall() {
268  1 try {
269  1 control.setDefaultThrowable(new RuntimeException());
270  0 fail("IllegalStateException expected");
271    } catch (IllegalStateException expected) {
272  1 assertEquals(
273    "method call on the mock needed before setting default Throwable",
274    expected.getMessage());
275    }
276    }
277   
 
278  1 toggle @Test
279    public void timesWithoutReturnValue() {
280  1 mock.booleanReturningMethod(1);
281  1 try {
282  1 expectLastCall().times(3);
283  0 fail();
284    } catch (IllegalStateException expected) {
285  1 assertEquals("last method called on mock is not a void method",
286    expected.getMessage());
287    }
288    }
289   
 
290  1 toggle @Test
291    public void asStubWithNonVoidMethod() {
292  1 mock.booleanReturningMethod(1);
293  1 try {
294  1 expectLastCall().asStub();
295  0 fail();
296    } catch (IllegalStateException expected) {
297  1 assertEquals("last method called on mock is not a void method",
298    expected.getMessage());
299    }
300    }
301   
302    }