Clover Coverage Report - EasyMock 3.0
Coverage timestamp: sam. mai 8 2010 14:37:27 CEST
91   206   21   4,33
0   162   0,23   21
21     1  
1    
 
  UsageExpectAndReturnTest       Line # 28 91 0% 21 0 100% 1.0
 
  (40)
 
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 UsageExpectAndReturnTest {
29   
30    private IMethods mock;
31   
 
32  40 toggle @Before
33    public void setup() {
34  40 mock = createMock(IMethods.class);
35    }
36   
 
37  2 toggle @Test
38    public void booleanType() {
39  2 expect(mock.booleanReturningMethod(4)).andReturn(true);
40  2 replay(mock);
41  2 assertEquals(true, mock.booleanReturningMethod(4));
42  2 verify(mock);
43    }
44   
 
45  2 toggle @Test
46    public void longType() {
47  2 expect(mock.longReturningMethod(4)).andReturn(12l);
48  2 replay(mock);
49  2 assertEquals(12, mock.longReturningMethod(4));
50  2 verify(mock);
51    }
52   
 
53  2 toggle @Test
54    public void floatType() {
55  2 expect(mock.floatReturningMethod(4)).andReturn(12f);
56  2 replay(mock);
57  2 assertEquals(12f, mock.floatReturningMethod(4), 0f);
58  2 verify(mock);
59    }
60   
 
61  2 toggle @Test
62    public void doubleType() {
63  2 expect(mock.doubleReturningMethod(4)).andReturn(12.0);
64  2 replay(mock);
65  2 assertEquals(12.0, mock.doubleReturningMethod(4), 0.0);
66  2 verify(mock);
67    }
68   
 
69  2 toggle @Test
70    public void object() {
71  2 expect(mock.objectReturningMethod(4)).andReturn("12");
72  2 replay(mock);
73  2 assertEquals("12", mock.objectReturningMethod(4));
74  2 verify(mock);
75    }
76   
 
77  2 toggle @Test
78    public void booleanAndRange() {
79  2 expect(mock.booleanReturningMethod(4)).andReturn(true).once();
80  2 replay(mock);
81  2 assertEquals(true, mock.booleanReturningMethod(4));
82  2 verify(mock);
83    }
84   
 
85  2 toggle @Test
86    public void longAndRange() {
87  2 expect(mock.longReturningMethod(4)).andReturn(12l).once();
88  2 replay(mock);
89  2 assertEquals(12, mock.longReturningMethod(4));
90  2 verify(mock);
91    }
92   
 
93  2 toggle @Test
94    public void floatAndRange() {
95  2 expect(mock.floatReturningMethod(4)).andReturn(12f).once();
96  2 replay(mock);
97  2 assertEquals(12f, mock.floatReturningMethod(4), 0f);
98  2 verify(mock);
99    }
100   
 
101  2 toggle @Test
102    public void doubleAndRange() {
103  2 expect(mock.doubleReturningMethod(4)).andReturn(12.0).once();
104  2 replay(mock);
105  2 assertEquals(12.0, mock.doubleReturningMethod(4), 0.0);
106  2 verify(mock);
107    }
108   
 
109  2 toggle @Test
110    public void objectAndRange() {
111  2 expect(mock.objectReturningMethod(4)).andReturn("12").once();
112  2 replay(mock);
113  2 assertEquals("12", mock.objectReturningMethod(4));
114  2 verify(mock);
115    }
116   
 
117  2 toggle @Test
118    public void booleanAndCount() {
119  2 expect(mock.booleanReturningMethod(4)).andReturn(true).times(2);
120  2 replay(mock);
121  2 assertEquals(true, mock.booleanReturningMethod(4));
122  2 assertEquals(true, mock.booleanReturningMethod(4));
123  2 verify(mock);
124    }
125   
 
126  2 toggle @Test
127    public void longAndCount() {
128  2 expect(mock.longReturningMethod(4)).andReturn(12l).times(2);
129  2 replay(mock);
130  2 assertEquals(12, mock.longReturningMethod(4));
131  2 assertEquals(12, mock.longReturningMethod(4));
132  2 verify(mock);
133    }
134   
 
135  2 toggle @Test
136    public void floatAndCount() {
137  2 expect(mock.floatReturningMethod(4)).andReturn(12f).times(2);
138  2 replay(mock);
139  2 assertEquals(12f, mock.floatReturningMethod(4), 0f);
140  2 assertEquals(12f, mock.floatReturningMethod(4), 0f);
141  2 verify(mock);
142    }
143   
 
144  2 toggle @Test
145    public void doubleAndCount() {
146  2 expect(mock.doubleReturningMethod(4)).andReturn(12.0).times(2);
147  2 replay(mock);
148  2 assertEquals(12.0, mock.doubleReturningMethod(4), 0.0);
149  2 assertEquals(12.0, mock.doubleReturningMethod(4), 0.0);
150  2 verify(mock);
151    }
152   
 
153  2 toggle @Test
154    public void objectAndCount() {
155  2 expect(mock.objectReturningMethod(4)).andReturn("12").times(2);
156  2 replay(mock);
157  2 assertEquals("12", mock.objectReturningMethod(4));
158  2 assertEquals("12", mock.objectReturningMethod(4));
159  2 verify(mock);
160    }
161   
 
162  2 toggle @Test
163    public void booleanAndMinMax() {
164  2 expect(mock.booleanReturningMethod(4)).andReturn(true).times(2, 3);
165  2 replay(mock);
166  2 assertEquals(true, mock.booleanReturningMethod(4));
167  2 assertEquals(true, mock.booleanReturningMethod(4));
168  2 verify(mock);
169    }
170   
 
171  2 toggle @Test
172    public void longAndMinMax() {
173  2 expect(mock.longReturningMethod(4)).andReturn(12l).times(2, 3);
174  2 replay(mock);
175  2 assertEquals(12, mock.longReturningMethod(4));
176  2 assertEquals(12, mock.longReturningMethod(4));
177  2 verify(mock);
178    }
179   
 
180  2 toggle @Test
181    public void floatAndMinMax() {
182  2 expect(mock.floatReturningMethod(4)).andReturn(12f).times(2, 3);
183  2 replay(mock);
184  2 assertEquals(12f, mock.floatReturningMethod(4), 0f);
185  2 assertEquals(12f, mock.floatReturningMethod(4), 0f);
186  2 verify(mock);
187    }
188   
 
189  2 toggle @Test
190    public void doubleAndMinMax() {
191  2 expect(mock.doubleReturningMethod(4)).andReturn(12.0).times(2, 3);
192  2 replay(mock);
193  2 assertEquals(12.0, mock.doubleReturningMethod(4), 0.0);
194  2 assertEquals(12.0, mock.doubleReturningMethod(4), 0.0);
195  2 verify(mock);
196    }
197   
 
198  2 toggle @Test
199    public void objectAndMinMax() {
200  2 expect(mock.objectReturningMethod(4)).andReturn("12").times(2, 3);
201  2 replay(mock);
202  2 assertEquals("12", mock.objectReturningMethod(4));
203  2 assertEquals("12", mock.objectReturningMethod(4));
204  2 verify(mock);
205    }
206    }