You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
in versions 1.1.0 and 1.1.1 the method ParameterisedTestMethodRunner.findChildForParams() may not define the "Description" object, causing the maven build to crash (maven-surefire-plugin + surefire-junit47 provider).
Version 1.0.6 does not have this problem (maven build runs without error).
Here is the error (from jvmRun.dump, the log of the maven itself will be given below, at the end):
org.apache.maven.surefire.testset.TestSetFailedException: Test mechanism :: null
at org.apache.maven.surefire.common.junit4.JUnit4RunListener.rethrowAnyTestMechanismFailures(JUnit4RunListener.java:223)
at org.apache.maven.surefire.junitcore.JUnitCoreWrapper.createRequestAndRun(JUnitCoreWrapper.java:138)
at org.apache.maven.surefire.junitcore.JUnitCoreWrapper.executeEager(JUnitCoreWrapper.java:107)
at org.apache.maven.surefire.junitcore.JUnitCoreWrapper.execute(JUnitCoreWrapper.java:83)
at org.apache.maven.surefire.junitcore.JUnitCoreWrapper.execute(JUnitCoreWrapper.java:75)
at org.apache.maven.surefire.junitcore.JUnitCoreProvider.invoke(JUnitCoreProvider.java:158)
at org.apache.maven.surefire.booter.ForkedBooter.invokeProviderInSameClassLoader(ForkedBooter.java:384)
at org.apache.maven.surefire.booter.ForkedBooter.runSuitesInProcess(ForkedBooter.java:345)
at org.apache.maven.surefire.booter.ForkedBooter.execute(ForkedBooter.java:126)
at org.apache.maven.surefire.booter.ForkedBooter.main(ForkedBooter.java:418)
Caused by: java.lang.NullPointerException
at org.apache.maven.surefire.junitcore.NonConcurrentRunListener.describesNewTestSet(NonConcurrentRunListener.java:124)
at org.apache.maven.surefire.junitcore.NonConcurrentRunListener.finishLastTestSetIfNecessary(NonConcurrentRunListener.java:107)
at org.apache.maven.surefire.junitcore.NonConcurrentRunListener.testStarted(NonConcurrentRunListener.java:101)
at org.junit.runner.notification.SynchronizedRunListener.testStarted(SynchronizedRunListener.java:80)
at org.junit.runner.notification.RunNotifier$5.notifyListener(RunNotifier.java:156)
at org.junit.runner.notification.RunNotifier$SafeNotifier.run(RunNotifier.java:72)
at org.junit.runner.notification.RunNotifier.fireTestStarted(RunNotifier.java:153)
at org.apache.maven.surefire.common.junit4.Notifier.fireTestStarted(Notifier.java:100)
at org.junit.internal.runners.model.EachTestNotifier.fireTestStarted(EachTestNotifier.java:42) at junitparams.internal.ParameterisedTestMethodRunner.runMethodInvoker(ParameterisedTestMethodRunner.java:45) at junitparams.internal.ParameterisedTestMethodRunner.runTestMethod(ParameterisedTestMethodRunner.java:40)
at junitparams.internal.ParameterisedTestClassRunner.runParameterisedTest(ParameterisedTestClassRunner.java:146)
at junitparams.JUnitParamsRunner.runChild(JUnitParamsRunner.java:446)
at junitparams.JUnitParamsRunner.runChild(JUnitParamsRunner.java:393)
at org.junit.runners.ParentRunner$4.run(ParentRunner.java:331)
at org.junit.runners.ParentRunner$1.schedule(ParentRunner.java:79)
at org.junit.runners.ParentRunner.runChildren(ParentRunner.java:329)
at org.junit.runners.ParentRunner.access$100(ParentRunner.java:66)
at org.junit.runners.ParentRunner$2.evaluate(ParentRunner.java:293)
at org.junit.runners.ParentRunner$3.evaluate(ParentRunner.java:306)
at org.junit.runners.ParentRunner.run(ParentRunner.java:413)
at org.junit.runners.Suite.runChild(Suite.java:128)
at org.junit.runners.Suite.runChild(Suite.java:27)
at org.junit.runners.ParentRunner$4.run(ParentRunner.java:331)
at org.junit.runners.ParentRunner$1.schedule(ParentRunner.java:79)
at org.junit.runners.ParentRunner.runChildren(ParentRunner.java:329)
at org.junit.runners.ParentRunner.access$100(ParentRunner.java:66)
at org.junit.runners.ParentRunner$2.evaluate(ParentRunner.java:293)
at org.junit.runners.ParentRunner$3.evaluate(ParentRunner.java:306)
at org.junit.runners.ParentRunner.run(ParentRunner.java:413)
at org.apache.maven.surefire.junitcore.JUnitCore.run(JUnitCore.java:55)
at org.apache.maven.surefire.junitcore.JUnitCoreWrapper.createRequestAndRun(JUnitCoreWrapper.java:137)
... 8 more
Platform: Java 8
Build tool: maven 3.8.3 (version is not important)
Framework: spring-boot 2.5.12, junit-vintage-engine 5.7.2, JUnit 4.13.2
JUnitParams: 1.1.1
maven-surefire-plugin is configured like this (maven, pom.xml):
My experiment showed that this happens if in a parameterized test a variable (object) is passed in more than one set of arguments, and at the same time it is mutated inside the test. In this case, Description will become null.
The simplest test to confirm the problem.
Command line:
mvn test >mvn.log
import junitparams.JUnitParamsRunner;
import junitparams.Parameters;
import org.junit.Test;
import org.junit.runner.RunWith;
import static org.junit.Assert.assertTrue;
@RunWith(JUnitParamsRunner.class)
public class JUnitParamsTest {
static class Container {
String value = "_1"; // initial
@Override
// having toString() is necessary! Without toString() "description" != null and the build passes without errors -)
public String toString() {
return "Container{" + "value='" + value + '\'' + '}';
}
}
private Object[] params() {
Container container = new Container();
return new Object[]{
new Object[]{container},
new Object[]{container}
};
}
@Test
@Parameters(method = "params")
public void test1(Container container) {
container.value = container.value + container.value;
assertTrue(true);
}
}
In the log file, all tests are executed without errors, but the build itself crashes.
As a result, it is even impossible to understand in which test (class) an error occurred.
[INFO]
[INFO] Results:
[INFO] [WARNING] Tests run: 1, Failures: 0, Errors: 0, Skipped: 0
[INFO]
[INFO] ------------------------------------------------------------------------ [INFO] BUILD FAILURE
[INFO] ------------------------------------------------------------------------
[INFO] Total time: 04:50 min
[INFO] Finished at: 2022-06-14T10:47:21+03:00
[INFO] ------------------------------------------------------------------------
[ERROR] Failed to execute goal org.apache.maven.plugins:maven-surefire-plugin:3.0.0-M7:test (default-test) on project cnc-app:
[ERROR]
[ERROR] Please refer to C:\Projects\CNC\cnc_core\core\cnc-app\target\surefire-reports for the individual test results. [ERROR] Please refer to dump files (if any exist) [date].dump, [date]-jvmRun[N].dump and [date].dumpstream.
[ERROR] There was an error in the forked process
[ERROR] Test mechanism :: null
[ERROR] org.apache.maven.surefire.booter.SurefireBooterForkException: There was an error in the forked process
[ERROR] Test mechanism :: null
[ERROR] at org.apache.maven.plugin.surefire.booterclient.ForkStarter.fork(ForkStarter.java:701)
[ERROR] at org.apache.maven.plugin.surefire.booterclient.ForkStarter.run(ForkStarter.java:311)
[ERROR] at org.apache.maven.plugin.surefire.booterclient.ForkStarter.run(ForkStarter.java:268)
[ERROR] at org.apache.maven.plugin.surefire.AbstractSurefireMojo.executeProvider(AbstractSurefireMojo.java:1334)
[ERROR] at org.apache.maven.plugin.surefire.AbstractSurefireMojo.executeAfterPreconditionsChecked(AbstractSurefireMojo.java:1167)
[ERROR] at org.apache.maven.plugin.surefire.AbstractSurefireMojo.execute(AbstractSurefireMojo.java:931)
[ERROR] at org.apache.maven.plugin.DefaultBuildPluginManager.executeMojo(DefaultBuildPluginManager.java:137)
[ERROR] at org.apache.maven.lifecycle.internal.MojoExecutor.execute(MojoExecutor.java:210)
[ERROR] at org.apache.maven.lifecycle.internal.MojoExecutor.execute(MojoExecutor.java:156)
[ERROR] at org.apache.maven.lifecycle.internal.MojoExecutor.execute(MojoExecutor.java:148)
[ERROR] at org.apache.maven.lifecycle.internal.LifecycleModuleBuilder.buildProject(LifecycleModuleBuilder.java:117)
[ERROR] at org.apache.maven.lifecycle.internal.LifecycleModuleBuilder.buildProject(LifecycleModuleBuilder.java:81)
[ERROR] at org.apache.maven.lifecycle.internal.builder.singlethreaded.SingleThreadedBuilder.build(SingleThreadedBuilder.java:56)
[ERROR] at org.apache.maven.lifecycle.internal.LifecycleStarter.execute(LifecycleStarter.java:128)
[ERROR] at org.apache.maven.DefaultMaven.doExecute(DefaultMaven.java:305)
[ERROR] at org.apache.maven.DefaultMaven.doExecute(DefaultMaven.java:192)
[ERROR] at org.apache.maven.DefaultMaven.execute(DefaultMaven.java:105)
[ERROR] at org.apache.maven.cli.MavenCli.execute(MavenCli.java:972)
[ERROR] at org.apache.maven.cli.MavenCli.doMain(MavenCli.java:293)
[ERROR] at org.apache.maven.cli.MavenCli.main(MavenCli.java:196)
[ERROR] at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
[ERROR] at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:62)
[ERROR] at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43)
[ERROR] at java.lang.reflect.Method.invoke(Method.java:498)
[ERROR] at org.codehaus.plexus.classworlds.launcher.Launcher.launchEnhanced(Launcher.java:282)
[ERROR] at org.codehaus.plexus.classworlds.launcher.Launcher.launch(Launcher.java:225)
[ERROR] at org.codehaus.plexus.classworlds.launcher.Launcher.mainWithExitCode(Launcher.java:406)
[ERROR] at org.codehaus.plexus.classworlds.launcher.Launcher.main(Launcher.java:347)
The text was updated successfully, but these errors were encountered:
vlalykin
changed the title
NPE when defining test method ("description") causing build to fail in maven
NPE when evaluating test method ("description") causing build to fail in maven
Jun 16, 2022
vlalykin
changed the title
NPE when evaluating test method ("description") causing build to fail in maven
Incorrect method 'description' evaluation (description is null) leading to NPE and build crash in maven
Jun 16, 2022
in versions 1.1.0 and 1.1.1 the method ParameterisedTestMethodRunner.findChildForParams() may not define the "Description" object, causing the maven build to crash (maven-surefire-plugin + surefire-junit47 provider).
Version 1.0.6 does not have this problem (maven build runs without error).
Here is the error (from jvmRun.dump, the log of the maven itself will be given below, at the end):
Platform: Java 8
Build tool: maven 3.8.3 (version is not important)
Framework: spring-boot 2.5.12, junit-vintage-engine 5.7.2, JUnit 4.13.2
JUnitParams: 1.1.1
maven-surefire-plugin is configured like this (maven, pom.xml):
My experiment showed that this happens if in a parameterized test a variable (object) is passed in more than one set of arguments, and at the same time it is mutated inside the test. In this case, Description will become null.
The simplest test to confirm the problem.
Command line:
In the log file, all tests are executed without errors, but the build itself crashes.
As a result, it is even impossible to understand in which test (class) an error occurred.
The text was updated successfully, but these errors were encountered: