Clover Coverage Report - EasyMock 2.4
Coverage timestamp: mer. juil. 2 2008 02:17:38 CEST
31   91   13   4,43
0   76   0,42   7
7     1,86  
1    
 
 
  RecordStateInvalidDefaultReturnValueTest       Line # 14 31 13 84,2% 0.84210527
 
  (6)
 
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.junit.Assert.*;
8   
9    import org.easymock.MockControl;
10    import org.junit.Before;
11    import org.junit.Test;
12   
13    @SuppressWarnings("deprecation")
 
14    public class RecordStateInvalidDefaultReturnValueTest {
15    MockControl<IMethods> control;
16   
17    IMethods mock;
18   
 
19  6 toggle @Before
20    public void setup() {
21  6 control = MockControl.createControl(IMethods.class);
22  6 mock = control.getMock();
23    }
24   
 
25  1 toggle @Test
26    public void setInvalidDefaultBooleanReturnValue() {
27  1 mock.oneArg(false);
28  1 try {
29  1 control.setDefaultReturnValue(false);
30  0 fail("IllegalStateException expected");
31    } catch (IllegalStateException e) {
32  1 assertEquals("incompatible return value type", e.getMessage());
33    }
34    }
35   
 
36  1 toggle @Test
37    public void setInvalidDefaultLongReturnValue() {
38  1 mock.oneArg(false);
39  1 try {
40  1 control.setDefaultReturnValue((long) 0);
41  0 fail("IllegalStateException expected");
42    } catch (IllegalStateException e) {
43  1 assertEquals("incompatible return value type", e.getMessage());
44    }
45    }
46   
 
47  1 toggle @Test
48    public void setInvalidDefaultFloatReturnValue() {
49  1 mock.oneArg(false);
50  1 try {
51  1 control.setDefaultReturnValue((float) 0);
52  0 fail("IllegalStateException expected");
53    } catch (IllegalStateException e) {
54  1 assertEquals("incompatible return value type", e.getMessage());
55    }
56    }
57   
 
58  1 toggle @Test
59    public void setInvalidDefaultDoubleReturnValue() {
60  1 mock.oneArg(false);
61  1 try {
62  1 control.setDefaultReturnValue((double) 0);
63  0 fail("IllegalStateException expected");
64    } catch (IllegalStateException e) {
65  1 assertEquals("incompatible return value type", e.getMessage());
66    }
67    }
68   
 
69  1 toggle @Test
70    public void setInvalidObjectDefaultReturnValue() {
71  1 mock.oneArg(false);
72  1 try {
73  1 control.setDefaultReturnValue(new Object());
74  0 fail("IllegalStateException expected");
75    } catch (IllegalStateException e) {
76  1 assertEquals("incompatible return value type", e.getMessage());
77    }
78    }
79   
 
80  1 toggle @Test
81    public void setDefaultReturnValueWithoutMethodCall() {
82  1 try {
83  1 control.setDefaultReturnValue(new Object());
84  0 fail("IllegalStateException expected");
85    } catch (IllegalStateException e) {
86  1 assertEquals(
87    "method call on the mock needed before setting default return value",
88    e.getMessage());
89    }
90    }
91    }