Clover Coverage Report - EasyMock 3.0
Coverage timestamp: sam. mai 8 2010 14:37:27 CEST
26   85   6   4,33
0   52   0,23   6
6     1  
1    
 
  UsageExpectAndDefaultReturnTest       Line # 31 26 0% 6 0 100% 1.0
 
  (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    * Same as UsageExpectAndReturnTest except that each mocked method is called
27    * twice to make sure the defaulting works fine.
28    *
29    * @author OFFIS, Tammo Freese
30    */
 
31    public class UsageExpectAndDefaultReturnTest {
32   
33    private IMethods mock;
34   
 
35  10 toggle @Before
36    public void setup() {
37  10 mock = createMock(IMethods.class);
38    }
39   
 
40  2 toggle @Test
41    public void booleanType() {
42  2 expect(mock.booleanReturningMethod(4)).andStubReturn(true);
43  2 replay(mock);
44  2 assertEquals(true, mock.booleanReturningMethod(4));
45  2 assertEquals(true, mock.booleanReturningMethod(4));
46  2 verify(mock);
47    }
48   
 
49  2 toggle @Test
50    public void longType() {
51  2 expect(mock.longReturningMethod(4)).andStubReturn(12l);
52  2 replay(mock);
53  2 assertEquals(12l, mock.longReturningMethod(4));
54  2 assertEquals(12l, mock.longReturningMethod(4));
55  2 verify(mock);
56    }
57   
 
58  2 toggle @Test
59    public void floatType() {
60  2 expect(mock.floatReturningMethod(4)).andStubReturn(12f);
61  2 replay(mock);
62  2 assertEquals(12f, mock.floatReturningMethod(4), 0f);
63  2 assertEquals(12f, mock.floatReturningMethod(4), 0f);
64  2 verify(mock);
65    }
66   
 
67  2 toggle @Test
68    public void doubleType() {
69  2 expect(mock.doubleReturningMethod(4)).andStubReturn(12.0);
70  2 replay(mock);
71  2 assertEquals(12.0, mock.doubleReturningMethod(4), 0.0);
72  2 assertEquals(12.0, mock.doubleReturningMethod(4), 0.0);
73  2 verify(mock);
74    }
75   
 
76  2 toggle @Test
77    public void objectType() {
78  2 expect(mock.objectReturningMethod(4)).andStubReturn("12");
79  2 replay(mock);
80  2 assertEquals("12", mock.objectReturningMethod(4));
81  2 assertEquals("12", mock.objectReturningMethod(4));
82  2 verify(mock);
83    }
84   
85    }