Clover Coverage Report - EasyMock 2.4
Coverage timestamp: mer. juil. 2 2008 02:17:38 CEST
23   75   9   4,6
0   62   0,39   5
5     1,8  
1    
 
 
  RecordStateInvalidMatcherTest       Line # 14 23 9 85,7% 0.85714287
 
  (4)
 
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 RecordStateInvalidMatcherTest {
15    MockControl<IMethods> control;
16   
17    IMethods mock;
18   
 
19  4 toggle @Before
20    public void setup() {
21  4 control = MockControl.createControl(IMethods.class);
22  4 mock = control.getMock();
23    }
24   
 
25  1 toggle @Test
26    public void setMatcherBeforeCallingMethods() {
27  1 try {
28  1 control.setMatcher(MockControl.ARRAY_MATCHER);
29  0 fail();
30    } catch (IllegalStateException expected) {
31  1 assertEquals(
32    "method call on the mock needed before setting matcher",
33    expected.getMessage());
34    }
35    }
36   
 
37  1 toggle @Test
38    public void setMatcherTwice() {
39  1 mock.simpleMethod();
40  1 control.setMatcher(MockControl.ARRAY_MATCHER);
41  1 try {
42  1 control.setMatcher(MockControl.EQUALS_MATCHER);
43  0 fail();
44    } catch (IllegalStateException expected) {
45  1 assertEquals(
46    "for method simpleMethod(), a matcher has already been set",
47    expected.getMessage());
48    }
49    }
50   
 
51  1 toggle @Test
52    public void setMatcherTwice2() {
53  1 mock.simpleMethodWithArgument("");
54  1 control.setMatcher(MockControl.ARRAY_MATCHER);
55  1 try {
56  1 control.setMatcher(MockControl.EQUALS_MATCHER);
57  0 fail();
58    } catch (IllegalStateException expected) {
59  1 assertEquals(
60    "for method simpleMethodWithArgument(...), a matcher has already been set",
61    expected.getMessage());
62    }
63    }
64   
 
65  1 toggle @Test
66    public void setSameMatcherTwice() {
67  1 mock.simpleMethod();
68  1 control.setMatcher(MockControl.ARRAY_MATCHER);
69  1 try {
70  1 control.setMatcher(MockControl.ARRAY_MATCHER);
71    } catch (IllegalStateException unexpected) {
72  0 fail("setting the same matcher should work");
73    }
74    }
75    }