| 1 |
|
|
| 2 |
|
|
| 3 |
|
|
| 4 |
|
|
| 5 |
|
package org.easymock.tests; |
| 6 |
|
|
| 7 |
|
import static org.easymock.EasyMock.*; |
| 8 |
|
import static org.junit.Assert.*; |
| 9 |
|
|
| 10 |
|
import org.easymock.MockControl; |
| 11 |
|
import org.junit.Before; |
| 12 |
|
import org.junit.Test; |
| 13 |
|
|
| 14 |
|
@SuppressWarnings("deprecation") |
|
|
|
| 80,8% |
Uncovered Elements: 23 (120) |
Complexity: 47 |
Complexity Density: 0,49 |
|
| 15 |
|
public class RecordStateMethodCallMissingTest { |
| 16 |
|
MockControl<IMethods> control; |
| 17 |
|
|
| 18 |
|
IMethods mock; |
| 19 |
|
|
|
|
|
| 100% |
Uncovered Elements: 0 (2) |
Complexity: 1 |
Complexity Density: 0,5 |
|
| 20 |
23
|
@Before... |
| 21 |
|
public void setup() { |
| 22 |
23
|
control = MockControl.createControl(IMethods.class); |
| 23 |
23
|
mock = control.getMock(); |
| 24 |
|
} |
| 25 |
|
|
|
|
|
| 75% |
Uncovered Elements: 1 (4) |
Complexity: 2 |
Complexity Density: 0,5 |
1
PASS
|
|
| 26 |
1
|
@Test... |
| 27 |
|
public void setBooleanReturnValueWithoutMethodCall() { |
| 28 |
1
|
try { |
| 29 |
1
|
control.setReturnValue(false); |
| 30 |
0
|
fail("IllegalStateException expected"); |
| 31 |
|
} catch (IllegalStateException expected) { |
| 32 |
1
|
assertEquals( |
| 33 |
|
"method call on the mock needed before setting return value", |
| 34 |
|
expected.getMessage()); |
| 35 |
|
} |
| 36 |
|
} |
| 37 |
|
|
|
|
|
| 75% |
Uncovered Elements: 1 (4) |
Complexity: 2 |
Complexity Density: 0,5 |
1
PASS
|
|
| 38 |
1
|
@Test... |
| 39 |
|
public void setLongReturnValueWithoutMethodCall() { |
| 40 |
1
|
try { |
| 41 |
1
|
control.setReturnValue(0); |
| 42 |
0
|
fail("IllegalStateException expected"); |
| 43 |
|
} catch (IllegalStateException expected) { |
| 44 |
1
|
assertEquals( |
| 45 |
|
"method call on the mock needed before setting return value", |
| 46 |
|
expected.getMessage()); |
| 47 |
|
} |
| 48 |
|
} |
| 49 |
|
|
|
|
|
| 75% |
Uncovered Elements: 1 (4) |
Complexity: 2 |
Complexity Density: 0,5 |
1
PASS
|
|
| 50 |
1
|
@Test... |
| 51 |
|
public void setFloatReturnValueWithoutMethodCall() { |
| 52 |
1
|
try { |
| 53 |
1
|
control.setReturnValue((float) 0.0); |
| 54 |
0
|
fail("IllegalStateException expected"); |
| 55 |
|
} catch (IllegalStateException expected) { |
| 56 |
1
|
assertEquals( |
| 57 |
|
"method call on the mock needed before setting return value", |
| 58 |
|
expected.getMessage()); |
| 59 |
|
} |
| 60 |
|
} |
| 61 |
|
|
|
|
|
| 75% |
Uncovered Elements: 1 (4) |
Complexity: 2 |
Complexity Density: 0,5 |
1
PASS
|
|
| 62 |
1
|
@Test... |
| 63 |
|
public void setDoubleReturnValueWithoutMethodCall() { |
| 64 |
1
|
try { |
| 65 |
1
|
control.setReturnValue(0.0); |
| 66 |
0
|
fail("IllegalStateException expected"); |
| 67 |
|
} catch (IllegalStateException expected) { |
| 68 |
1
|
assertEquals( |
| 69 |
|
"method call on the mock needed before setting return value", |
| 70 |
|
expected.getMessage()); |
| 71 |
|
} |
| 72 |
|
} |
| 73 |
|
|
|
|
|
| 75% |
Uncovered Elements: 1 (4) |
Complexity: 2 |
Complexity Density: 0,5 |
1
PASS
|
|
| 74 |
1
|
@Test... |
| 75 |
|
public void setObjectReturnValueWithoutMethodCall() { |
| 76 |
1
|
try { |
| 77 |
1
|
control.setReturnValue(null); |
| 78 |
0
|
fail("IllegalStateException expected"); |
| 79 |
|
} catch (IllegalStateException expected) { |
| 80 |
1
|
assertEquals( |
| 81 |
|
"method call on the mock needed before setting return value", |
| 82 |
|
expected.getMessage()); |
| 83 |
|
} |
| 84 |
|
} |
| 85 |
|
|
|
|
|
| 75% |
Uncovered Elements: 1 (4) |
Complexity: 2 |
Complexity Density: 0,5 |
1
PASS
|
|
| 86 |
1
|
@Test... |
| 87 |
|
public void setVoidCallableWithoutMethodCall() { |
| 88 |
1
|
try { |
| 89 |
1
|
control.setVoidCallable(); |
| 90 |
0
|
fail("IllegalStateException expected"); |
| 91 |
|
} catch (IllegalStateException expected) { |
| 92 |
1
|
assertEquals( |
| 93 |
|
"method call on the mock needed before setting void callable", |
| 94 |
|
expected.getMessage()); |
| 95 |
|
} |
| 96 |
|
} |
| 97 |
|
|
|
|
|
| 75% |
Uncovered Elements: 1 (4) |
Complexity: 2 |
Complexity Density: 0,5 |
1
PASS
|
|
| 98 |
1
|
@Test... |
| 99 |
|
public void setThrowableWithoutMethodCall() { |
| 100 |
1
|
try { |
| 101 |
1
|
control.setThrowable(new RuntimeException()); |
| 102 |
0
|
fail("IllegalStateException expected"); |
| 103 |
|
} catch (IllegalStateException expected) { |
| 104 |
1
|
assertEquals( |
| 105 |
|
"method call on the mock needed before setting Throwable", |
| 106 |
|
expected.getMessage()); |
| 107 |
|
} |
| 108 |
|
} |
| 109 |
|
|
|
|
|
| 75% |
Uncovered Elements: 1 (4) |
Complexity: 2 |
Complexity Density: 0,5 |
1
PASS
|
|
| 110 |
1
|
@Test... |
| 111 |
|
public void setBooleanReturnValueCountWithoutMethodCall() { |
| 112 |
1
|
try { |
| 113 |
1
|
control.setReturnValue(false, 3); |
| 114 |
0
|
fail("IllegalStateException expected"); |
| 115 |
|
} catch (IllegalStateException expected) { |
| 116 |
1
|
assertEquals( |
| 117 |
|
"method call on the mock needed before setting return value", |
| 118 |
|
expected.getMessage()); |
| 119 |
|
} |
| 120 |
|
} |
| 121 |
|
|
|
|
|
| 75% |
Uncovered Elements: 1 (4) |
Complexity: 2 |
Complexity Density: 0,5 |
1
PASS
|
|
| 122 |
1
|
@Test... |
| 123 |
|
public void setLongReturnValueCountWithoutMethodCall() { |
| 124 |
1
|
try { |
| 125 |
1
|
control.setReturnValue(0, 3); |
| 126 |
0
|
fail("IllegalStateException expected"); |
| 127 |
|
} catch (IllegalStateException expected) { |
| 128 |
1
|
assertEquals( |
| 129 |
|
"method call on the mock needed before setting return value", |
| 130 |
|
expected.getMessage()); |
| 131 |
|
} |
| 132 |
|
} |
| 133 |
|
|
|
|
|
| 75% |
Uncovered Elements: 1 (4) |
Complexity: 2 |
Complexity Density: 0,5 |
1
PASS
|
|
| 134 |
1
|
@Test... |
| 135 |
|
public void setFloatReturnValueCountWithoutMethodCall() { |
| 136 |
1
|
try { |
| 137 |
1
|
control.setReturnValue((float) 0.0, 3); |
| 138 |
0
|
fail("IllegalStateException expected"); |
| 139 |
|
} catch (IllegalStateException expected) { |
| 140 |
1
|
assertEquals( |
| 141 |
|
"method call on the mock needed before setting return value", |
| 142 |
|
expected.getMessage()); |
| 143 |
|
} |
| 144 |
|
} |
| 145 |
|
|
|
|
|
| 75% |
Uncovered Elements: 1 (4) |
Complexity: 2 |
Complexity Density: 0,5 |
1
PASS
|
|
| 146 |
1
|
@Test... |
| 147 |
|
public void setDoubleReturnValueCountWithoutMethodCall() { |
| 148 |
1
|
try { |
| 149 |
1
|
control.setReturnValue(0.0, 3); |
| 150 |
0
|
fail("IllegalStateException expected"); |
| 151 |
|
} catch (IllegalStateException expected) { |
| 152 |
1
|
assertEquals( |
| 153 |
|
"method call on the mock needed before setting return value", |
| 154 |
|
expected.getMessage()); |
| 155 |
|
} |
| 156 |
|
} |
| 157 |
|
|
|
|
|
| 75% |
Uncovered Elements: 1 (4) |
Complexity: 2 |
Complexity Density: 0,5 |
1
PASS
|
|
| 158 |
1
|
@Test... |
| 159 |
|
public void setObjectReturnValueCountWithoutMethodCall() { |
| 160 |
1
|
try { |
| 161 |
1
|
control.setReturnValue(null, 3); |
| 162 |
0
|
fail("IllegalStateException expected"); |
| 163 |
|
} catch (IllegalStateException expected) { |
| 164 |
1
|
assertEquals( |
| 165 |
|
"method call on the mock needed before setting return value", |
| 166 |
|
expected.getMessage()); |
| 167 |
|
} |
| 168 |
|
} |
| 169 |
|
|
|
|
|
| 75% |
Uncovered Elements: 1 (4) |
Complexity: 2 |
Complexity Density: 0,5 |
1
PASS
|
|
| 170 |
1
|
@Test... |
| 171 |
|
public void setVoidCallableCountWithoutMethodCall() { |
| 172 |
1
|
try { |
| 173 |
1
|
control.setVoidCallable(3); |
| 174 |
0
|
fail("IllegalStateException expected"); |
| 175 |
|
} catch (IllegalStateException expected) { |
| 176 |
1
|
assertEquals( |
| 177 |
|
"method call on the mock needed before setting void callable", |
| 178 |
|
expected.getMessage()); |
| 179 |
|
} |
| 180 |
|
} |
| 181 |
|
|
|
|
|
| 75% |
Uncovered Elements: 1 (4) |
Complexity: 2 |
Complexity Density: 0,5 |
1
PASS
|
|
| 182 |
1
|
@Test... |
| 183 |
|
public void setThrowableCountWithoutMethodCall() { |
| 184 |
1
|
try { |
| 185 |
1
|
control.setThrowable(new RuntimeException(), 3); |
| 186 |
0
|
fail("IllegalStateException expected"); |
| 187 |
|
} catch (IllegalStateException expected) { |
| 188 |
1
|
assertEquals( |
| 189 |
|
"method call on the mock needed before setting Throwable", |
| 190 |
|
expected.getMessage()); |
| 191 |
|
} |
| 192 |
|
} |
| 193 |
|
|
|
|
|
| 75% |
Uncovered Elements: 1 (4) |
Complexity: 2 |
Complexity Density: 0,5 |
1
PASS
|
|
| 194 |
1
|
@Test... |
| 195 |
|
public void setBooleanDefaultReturnValueWithoutMethodCall() { |
| 196 |
1
|
try { |
| 197 |
1
|
control.setDefaultReturnValue(false); |
| 198 |
0
|
fail("IllegalStateException expected"); |
| 199 |
|
} catch (IllegalStateException expected) { |
| 200 |
1
|
assertEquals( |
| 201 |
|
"method call on the mock needed before setting default return value", |
| 202 |
|
expected.getMessage()); |
| 203 |
|
} |
| 204 |
|
} |
| 205 |
|
|
|
|
|
| 75% |
Uncovered Elements: 1 (4) |
Complexity: 2 |
Complexity Density: 0,5 |
1
PASS
|
|
| 206 |
1
|
@Test... |
| 207 |
|
public void setLongDefaultReturnValueWithoutMethodCall() { |
| 208 |
1
|
try { |
| 209 |
1
|
control.setDefaultReturnValue(0); |
| 210 |
0
|
fail("IllegalStateException expected"); |
| 211 |
|
} catch (IllegalStateException expected) { |
| 212 |
1
|
assertEquals( |
| 213 |
|
"method call on the mock needed before setting default return value", |
| 214 |
|
expected.getMessage()); |
| 215 |
|
} |
| 216 |
|
} |
| 217 |
|
|
|
|
|
| 75% |
Uncovered Elements: 1 (4) |
Complexity: 2 |
Complexity Density: 0,5 |
1
PASS
|
|
| 218 |
1
|
@Test... |
| 219 |
|
public void setFloatDefaultReturnValueWithoutMethodCall() { |
| 220 |
1
|
try { |
| 221 |
1
|
control.setDefaultReturnValue((float) 0.0); |
| 222 |
0
|
fail("IllegalStateException expected"); |
| 223 |
|
} catch (IllegalStateException expected) { |
| 224 |
1
|
assertEquals( |
| 225 |
|
"method call on the mock needed before setting default return value", |
| 226 |
|
expected.getMessage()); |
| 227 |
|
} |
| 228 |
|
} |
| 229 |
|
|
|
|
|
| 75% |
Uncovered Elements: 1 (4) |
Complexity: 2 |
Complexity Density: 0,5 |
1
PASS
|
|
| 230 |
1
|
@Test... |
| 231 |
|
public void setDoubleDefaultReturnValueWithoutMethodCall() { |
| 232 |
1
|
try { |
| 233 |
1
|
control.setDefaultReturnValue(0.0); |
| 234 |
0
|
fail("IllegalStateException expected"); |
| 235 |
|
} catch (IllegalStateException expected) { |
| 236 |
1
|
assertEquals( |
| 237 |
|
"method call on the mock needed before setting default return value", |
| 238 |
|
expected.getMessage()); |
| 239 |
|
} |
| 240 |
|
} |
| 241 |
|
|
|
|
|
| 75% |
Uncovered Elements: 1 (4) |
Complexity: 2 |
Complexity Density: 0,5 |
1
PASS
|
|
| 242 |
1
|
@Test... |
| 243 |
|
public void setObjectDefaultReturnValueWithoutMethodCall() { |
| 244 |
1
|
try { |
| 245 |
1
|
control.setDefaultReturnValue(null); |
| 246 |
0
|
fail("IllegalStateException expected"); |
| 247 |
|
} catch (IllegalStateException expected) { |
| 248 |
1
|
assertEquals( |
| 249 |
|
"method call on the mock needed before setting default return value", |
| 250 |
|
expected.getMessage()); |
| 251 |
|
} |
| 252 |
|
} |
| 253 |
|
|
|
|
|
| 75% |
Uncovered Elements: 1 (4) |
Complexity: 2 |
Complexity Density: 0,5 |
1
PASS
|
|
| 254 |
1
|
@Test... |
| 255 |
|
public void setDefaultVoidCallableWithoutMethodCall() { |
| 256 |
1
|
try { |
| 257 |
1
|
control.setDefaultVoidCallable(); |
| 258 |
0
|
fail("IllegalStateException expected"); |
| 259 |
|
} catch (IllegalStateException expected) { |
| 260 |
1
|
assertEquals( |
| 261 |
|
"method call on the mock needed before setting default void callable", |
| 262 |
|
expected.getMessage()); |
| 263 |
|
} |
| 264 |
|
} |
| 265 |
|
|
|
|
|
| 75% |
Uncovered Elements: 1 (4) |
Complexity: 2 |
Complexity Density: 0,5 |
1
PASS
|
|
| 266 |
1
|
@Test... |
| 267 |
|
public void setDefaultThrowableWithoutMethodCall() { |
| 268 |
1
|
try { |
| 269 |
1
|
control.setDefaultThrowable(new RuntimeException()); |
| 270 |
0
|
fail("IllegalStateException expected"); |
| 271 |
|
} catch (IllegalStateException expected) { |
| 272 |
1
|
assertEquals( |
| 273 |
|
"method call on the mock needed before setting default Throwable", |
| 274 |
|
expected.getMessage()); |
| 275 |
|
} |
| 276 |
|
} |
| 277 |
|
|
|
|
|
| 80% |
Uncovered Elements: 1 (5) |
Complexity: 2 |
Complexity Density: 0,4 |
1
PASS
|
|
| 278 |
1
|
@Test... |
| 279 |
|
public void timesWithoutReturnValue() { |
| 280 |
1
|
mock.booleanReturningMethod(1); |
| 281 |
1
|
try { |
| 282 |
1
|
expectLastCall().times(3); |
| 283 |
0
|
fail(); |
| 284 |
|
} catch (IllegalStateException expected) { |
| 285 |
1
|
assertEquals("last method called on mock is not a void method", |
| 286 |
|
expected.getMessage()); |
| 287 |
|
} |
| 288 |
|
} |
| 289 |
|
|
|
|
|
| 80% |
Uncovered Elements: 1 (5) |
Complexity: 2 |
Complexity Density: 0,4 |
1
PASS
|
|
| 290 |
1
|
@Test... |
| 291 |
|
public void asStubWithNonVoidMethod() { |
| 292 |
1
|
mock.booleanReturningMethod(1); |
| 293 |
1
|
try { |
| 294 |
1
|
expectLastCall().asStub(); |
| 295 |
0
|
fail(); |
| 296 |
|
} catch (IllegalStateException expected) { |
| 297 |
1
|
assertEquals("last method called on mock is not a void method", |
| 298 |
|
expected.getMessage()); |
| 299 |
|
} |
| 300 |
|
} |
| 301 |
|
|
| 302 |
|
} |