powermock: ExpectedException.expectMessage AssertionError lost with PowerMockRunner
From dietrich…@gmail.com on March 09, 2012 07:58:14
What steps will reproduce the problem? Run this test class:
@RunWith(PowerMockRunner.class)
public class ExpectedExceptionTest {
@Rule
public ExpectedException thrown = ExpectedException.none();
@Test
public void testExpectedException() {
thrown.expect(IllegalStateException.class);
thrown.expectMessage("expected message");
throw new IllegalStateException("surprise message");
}
}
What is the expected output? What do you see instead? Expected output:
java.lang.AssertionError:
Expected: (exception with message a string containing "expected message" and an instance of java.lang.IllegalStateException)
got: <java.lang.IllegalStateException: surprise message>
Instead I see:
java.lang.IllegalStateException: surprise message
Without the PowerMockRunner the expected AssertionError is shown in the output. What version of the product are you using? On what operating system? 1.4.11
_Original issue: http://code.google.com/p/powermock/issues/detail?id=376_
About this issue
- Original URL
- State: open
- Created 9 years ago
- Comments: 19 (5 by maintainers)
Commits related to this issue
- Issue #396 ExpectedException.expectMessage AssertionError lost with PowerMockRunner — committed to rockydcoder/powermock by deleted user 7 years ago
From ronald.b…@gmail.com on September 26, 2013 13:02:45
Update: instead of the Powermock specific PowerMockTestRule above i am now using a more generic Version: TestRuleAdapter: