Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

throw IllegalStateException if methodInvoker is Fail #144

Open
wants to merge 1 commit into
base: master
Choose a base branch
from
Open
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
@@ -1,13 +1,14 @@
package junitparams.internal;

import java.lang.reflect.Field;

import org.junit.internal.AssumptionViolatedException;
import org.junit.internal.runners.model.EachTestNotifier;
import org.junit.internal.runners.statements.Fail;
import org.junit.runner.Description;
import org.junit.runner.notification.RunNotifier;
import org.junit.runners.model.Statement;

import java.lang.reflect.Field;

/**
* Testmethod-level functionalities for parameterised tests
*
Expand Down Expand Up @@ -68,6 +69,14 @@ private Description findChildForParams(Statement methodInvoker, Description meth
}

private InvokeParameterisedMethod findParameterisedMethodInvokerInChain(Statement methodInvoker) {
if (methodInvoker != null && methodInvoker instanceof Fail) {
try {
methodInvoker.evaluate();
} catch (Throwable throwable) {
throw new IllegalStateException("Instantiation failed", throwable);
Copy link
Contributor

@goostleek goostleek Jan 3, 2018

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I think calling methodInvoker.evaluate() would be enough for the fix. Ther's no need to catch the evaluation result and wraping up the original cause in IllegalStateException. WDYT?

Copy link
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The reason for that is that evaluate is throwing Throwable and thus method findParametr... will not compile.

}
}

while (methodInvoker != null && !(methodInvoker instanceof InvokeParameterisedMethod))
methodInvoker = nextChainedInvoker(methodInvoker);

Expand Down