Open GoogleCodeExporter opened 9 years ago
I'm not familiar with assumeTrue(..) and I've never used it. It would be cool
if PowerMock could support it though. If you're up for it please help out and
provide a patch to the PowerMockRunner.
Original comment by johan.ha...@gmail.com
on 29 Nov 2012 at 6:45
[deleted comment]
[deleted comment]
Well, I have no patch, but perhaps some information:
The PowerMockJUnit44MethodRunner overrides the method runTestMethod of
MethodRoadie.
In the original code (junit v4.11) there is an if statement that catches those
exceptions:
-------------------- 8< ------------------
protected void runTestMethod() {
try {
fTestMethod.invoke(fTest);
if (fTestMethod.expectsException()) {
addFailure(new AssertionError("Expected exception: " + fTestMethod.getExpectedException().getName()));
}
} catch (InvocationTargetException e) {
Throwable actual = e.getTargetException();
*if (actual instanceof AssumptionViolatedException) {
return;
}* else if (!fTestMethod.expectsException()) {
addFailure(actual);
} else if (fTestMethod.isUnexpected(actual)) {
String message = "Unexpected exception, expected<" + fTestMethod.getExpectedException().getName() + "> but was<"
+ actual.getClass().getName() + ">";
addFailure(new Exception(message, actual));
}
} catch (Throwable e) {
addFailure(e);
}
}
-------------------- 8< ------------------
Original comment by openid4...@gmail.com
on 12 Jun 2013 at 8:08
This patch works for me.
(org.powermock.modules.junit4.internal.impl.PowerMockJUnit44RunnerDelegateImpl)
powermock 1.5
junit 4.11
Original comment by openid4...@gmail.com
on 12 Jun 2013 at 8:59
Attachments:
Couldn't get the patch to work but I tried to implement it myself. Please try
it out by building PowerMock from source. Thanks for your help!
Original comment by johan.ha...@gmail.com
on 13 Jun 2013 at 6:03
Well, the exception has gone, but the test case is marked as passed, instead of
skipped?
Looking into the source, there might be missing some skipping code (marked with
XXX):
e.g. runNotifier.fireTestIgnored(description)
[org.powermock.modules.junit4.internal.impl.PowerMockJUnit44RunnerDelegateImpl:3
43]
----------------------- 8< ----------------------
if (throwableName.equals("org.junit.internal.AssumptionViolatedException") || throwableName.startsWith("org.junit.Assume$AssumptionViolatedException")) {
XXXXXXXXXXXX
return;
} else if (!(Boolean) Whitebox.invokeMethod(testMethod, "expectsException")) {
----------------------- 8< ----------------------
Original comment by openid4...@gmail.com
on 29 Jul 2013 at 1:29
Please provide a patch and I'll include it in the next release.
Original comment by johan.ha...@gmail.com
on 30 Jul 2013 at 5:04
Original issue reported on code.google.com by
funk.up...@gmail.com
on 13 Nov 2012 at 11:39