sbabcoc / JUnit-Foundation

JUnit Foundation is a lightweight collection of JUnit watchers, interfaces, and static utility classes that supplement and augment the functionality provided by the JUnit API.
Apache License 2.0
22 stars 6 forks source link

Using JUnitParams causes NullPointerException #65

Closed liamtsava closed 4 years ago

liamtsava commented 4 years ago

Using JUnitParams for running parameterized tests fail with NullPointerException. To reproduce the issue you can use next branch Just deploy RP locally and run mvn test to start com.epam.reportportal.example.junit.logging.JUnitParamsTest or use running via Junit plugin for more detailed stacktrace

15:30:30.079 DEBUG c.n.a.j.RunReflectiveCall - main - beforeInvocation: logPlain(17, false) 0 15:30:30.128 DEBUG c.n.a.j.RunReflectiveCall - main - afterInvocation: logPlain(17, false) 0 15:30:30.021 DEBUG c.n.a.j.RunAnnouncer - main - testStarted: logPlain(17, false) 0 15:30:30.165 DEBUG c.n.a.j.RunAnnouncer - main - testStarted: logPlain(22, true) 1 15:30:30.168 DEBUG c.n.a.j.RunReflectiveCall - main - beforeInvocation: logPlain(22, true) 1 15:30:30.169 DEBUG c.n.a.j.RunReflectiveCall - main - afterInvocation: logPlain(22, true) 1 15:30:30.158 DEBUG c.n.a.j.RunAnnouncer - main - testFinished: logPlain(17, false) 0 15:30:30.164 DEBUG c.n.a.j.CreateTest - main - testObjectCreated: com.epam.reportportal.example.junit.logging.JUnitParamsTest@7645b7d 15:30:30.171 DEBUG c.n.a.j.RunAnnouncer - main - testFinished: logPlain(22, true) 1 15:30:30.179 DEBUG c.n.a.j.Run - main - runFinished: junitparams.JUnitParamsRunner@45eab322

Process finished with exit code 255

java.lang.NullPointerException at com.nordstrom.automation.junit.RunAnnouncer.isSupported(RunAnnouncer.java:144) at com.nordstrom.automation.junit.RunAnnouncer.testStarted(RunAnnouncer.java:27) at org.junit.runner.notification.SynchronizedRunListener.testStarted(SynchronizedRunListener.java:49) at org.junit.runner.notification.RunNotifier$3.notifyListener(RunNotifier.java:121) at org.junit.runner.notification.RunNotifier$SafeNotifier.run(RunNotifier.java:72) at org.junit.runner.notification.RunNotifier.fireTestStarted(RunNotifier.java:118) at org.junit.internal.runners.model.EachTestNotifier.fireTestStarted(EachTestNotifier.java:42) at junitparams.internal.ParameterisedTestMethodRunner.runMethodInvoker(ParameterisedTestMethodRunner.java:45)

sbabcoc commented 4 years ago

The version of agent-java-junit that's exhibiting this failure is using an old version of JUnit Foundation. Try upgrading to the latest version with Maven dependency management to see if this improves your results. I've submitted a PR in agent-java-junit that upgrades JUnit Foundation, but this has not been merged yet.

sbabcoc commented 4 years ago

By the way, where can I find instructions to deploy RP locally?

sbabcoc commented 4 years ago

JUnitParams is a very weird animal. The project is not quite finished. The projected hasn't been updated in more than two years, and it has 25 open issues logged against it. Of special interest is this: https://github.com/Pragmatists/JUnitParams/issues/151

The implementation doesn't quite mesh with the ethos of JUnit's extension points. However, while watching this example run, I discovered that I had the ability to improve the usability of the ArtifactParams feature dramatically by capturing the ReflectiveCallable object in the AtomIdentity run watcher.

sbabcoc commented 4 years ago

JUnit Foundation version 12.0.0 has been released. I open a pull request against your JUnitParams example branch: https://github.com/reportportal/examples-java/pull/44

sbabcoc commented 4 years ago

I've merged a flurry of revisions to resolve this issue and enhance the usability of the ArtifactParams feature. I published a new release with these revisions and upgraded your branch to use them. Note that you'll need to hold off merging this branch until a new release of agent-java-junit is published. For now, you'll need to build and install the 5.0.0-BETA-9-SNAPSHOT release locally.

sbabcoc commented 4 years ago

This issue has been resolved.