Clover Coverage Report - EasyMock 3.0
Coverage timestamp: sam. mai 8 2010 14:37:27 CEST
28   95   11   4,67
0   65   0,39   6
6     1,83  
1    
 
  RecordStateInvalidRangeTest       Line # 28 28 0% 11 5 85,3% 0.85294116
 
  (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.tests;
18   
19    import static org.easymock.EasyMock.*;
20    import static org.junit.Assert.*;
21   
22    import org.junit.Before;
23    import org.junit.Test;
24   
25    /**
26    * @author OFFIS, Tammo Freese
27    */
 
28    public class RecordStateInvalidRangeTest {
29   
30    private IMethods mock;
31   
 
32  10 toggle @Before
33    public void setup() {
34  10 mock = createMock(IMethods.class);
35    }
36   
 
37  2 toggle @Test
38    public void setOpenCallCountTwice() {
39  2 mock.simpleMethod();
40  2 try {
41  2 expectLastCall().atLeastOnce().atLeastOnce();
42  0 fail();
43    } catch (final IllegalStateException expected) {
44  2 assertEquals("last method called on mock already has a non-fixed count set.", expected
45    .getMessage());
46    }
47    }
48   
 
49  2 toggle @Test
50    public void setCloseCallAfterOpenOne() {
51  2 mock.simpleMethod();
52  2 try {
53  2 expectLastCall().atLeastOnce().once();
54  0 fail();
55    } catch (final IllegalStateException expected) {
56  2 assertEquals("last method called on mock already has a non-fixed count set.", expected
57    .getMessage());
58    }
59    }
60   
 
61  2 toggle @Test
62    public void setIllegalMinimumCount() {
63  2 mock.simpleMethod();
64  2 final int NEGATIVE = -1;
65  2 try {
66  2 expectLastCall().times(NEGATIVE, 2);
67  0 fail();
68    } catch (final IllegalArgumentException expected) {
69  2 assertEquals("minimum must be >= 0", expected.getMessage());
70    }
71    }
72   
 
73  2 toggle @Test
74    public void setIllegalMaximumCount() {
75  2 mock.simpleMethod();
76  2 final int NON_POSITIVE = 0;
77  2 try {
78  2 expectLastCall().times(0, NON_POSITIVE);
79  0 fail();
80    } catch (final IllegalArgumentException expected) {
81  2 assertEquals("maximum must be >= 1", expected.getMessage());
82    }
83    }
84   
 
85  2 toggle @Test
86    public void setMinimumBiggerThanMaximum() {
87  2 mock.simpleMethod();
88  2 try {
89  2 expectLastCall().times(4, 3);
90  0 fail();
91    } catch (final IllegalArgumentException expected) {
92  2 assertEquals("minimum must be <= maximum", expected.getMessage());
93    }
94    }
95    }