Clover Coverage Report - EasyMock 2.4
Coverage timestamp: mer. juil. 2 2008 02:17:38 CEST
22   83   10   3,67
0   68   0,45   3
6     1,67  
2    
 
 
  StacktraceTest       Line # 14 21 9 96,2% 0.96153843
  StacktraceTest.ToStringThrowsException       Line # 26 1 1 100% 1.0
 
  (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 StacktraceTest {
15   
16    private MockControl<IMethods> control;
17   
18    private IMethods mock;
19   
 
20  4 toggle @Before
21    public void setup() {
22  4 control = MockControl.createStrictControl(IMethods.class);
23  4 mock = control.getMock();
24    }
25   
 
26    private static class ToStringThrowsException {
 
27  4 toggle @Override
28    public String toString() {
29  4 throw new NullPointerException();
30    }
31    }
32   
 
33  1 toggle @Test
34    public void assertRecordStateNoFillInStacktraceWhenExceptionNotFromEasyMock() {
35  1 mock.oneArg(new ToStringThrowsException());
36  1 try {
37  1 mock.oneArg(new ToStringThrowsException());
38    } catch (NullPointerException expected) {
39  1 assertTrue("stack trace must not be cut",
40    Util.getStackTrace(expected).indexOf(
41    ToStringThrowsException.class.getName()) > 0);
42    }
43    }
44   
 
45  1 toggle @Test
46    public void assertReplayNoFillInStacktraceWhenExceptionNotFromEasyMock() {
47  1 mock.oneArg(new ToStringThrowsException());
48  1 try {
49  1 control.replay();
50    } catch (NullPointerException expected) {
51  1 assertTrue("stack trace must not be cut",
52    Util.getStackTrace(expected).indexOf(
53    ToStringThrowsException.class.getName()) > 0);
54    }
55    }
56   
 
57  1 toggle @Test
58    public void assertReplayStateNoFillInStacktraceWhenExceptionNotFromEasyMock() {
59  1 control.replay();
60  1 try {
61  1 mock.oneArg(new ToStringThrowsException());
62    } catch (NullPointerException expected) {
63  1 assertTrue("stack trace must not be cut",
64    Util.getStackTrace(expected).indexOf(
65    ToStringThrowsException.class.getName()) > 0);
66    }
67    }
68   
 
69  1 toggle @Test
70    public void assertVerifyNoFillInStacktraceWhenExceptionNotFromEasyMock() {
71  1 mock.oneArg(new ToStringThrowsException());
72  1 control.setReturnValue("");
73  1 control.replay();
74  1 try {
75  1 control.verify();
76  0 fail();
77    } catch (NullPointerException expected) {
78  1 assertTrue("stack trace must not be cut",
79    Util.getStackTrace(expected).indexOf(
80    ToStringThrowsException.class.getName()) > 0);
81    }
82    }
83    }