IQSS / IQSS/dataverse

Can't run a unit test from Netbeans

Open
#10,728 7 comments 0 reactions 0 assignees View on GitHub

Nobody has claimed this yet.

Dominant language
Java
Stars
1.1k
Forks
564
Avg merge
2d 2h
Merged PRs (30d)
29

Description

For over a decade I've been able to run unit tests from within Netbeans. This broke within the past year or so, perhaps with a JUnit upgrade? I'm not sure.

These days, when I click "Run -> Test File" like this...

Screenshot 2024-07-26 at 10 36 05 AM

... I get errors like this:

cd /Users/PDurbin/github/iqss/dataverse; JAVA_HOME=/Users/PDurbin/.sdkman/candidates/java/17.0.11-tem "/Applications/Apache NetBeans.app/Contents/Resources/netbeans/java/maven/bin/mvn" -Dtest=edu.harvard.iq.dataverse.util.json.JsonUtilTest --no-transfer-progress surefire:test
Running NetBeans Compile On Save execution. Phase execution is skipped and output directories of dependency projects (with Compile on Save turned on) will be used instead of their jar artifacts.
Scanning for projects...

----------------------< edu.harvard.iq:dataverse >----------------------
Building dataverse 6.3
  from pom.xml
--------------------------------[ war ]---------------------------------

--- surefire:3.2.5:test (default-cli) @ dataverse ---
Using auto detected provider org.apache.maven.surefire.junitplatform.JUnitPlatformProvider

-------------------------------------------------------
 T E S T S
-------------------------------------------------------
Error: Could not find or load main class ${surefire.jacoco.args}
Caused by: java.lang.ClassNotFoundException: ${surefire.jacoco.args}

Results:

Tests run: 0, Failures: 0, Errors: 0, Skipped: 0

------------------------------------------------------------------------
BUILD FAILURE
------------------------------------------------------------------------
Total time:  0.950 s
Finished at: 2024-07-26T10:36:30-04:00
------------------------------------------------------------------------
Failed to execute goal org.apache.maven.plugins:maven-surefire-plugin:3.2.5:test (default-cli) on project dataverse: 

Please refer to /Users/PDurbin/github/iqss/dataverse/target/surefire-reports for the individual test results.
Please refer to dump files (if any exist) [date].dump, [date]-jvmRun[N].dump and [date].dumpstream.
The forked VM terminated without properly saying goodbye. VM crash or System.exit called?
Command was /bin/sh -c cd '/Users/PDurbin/github/iqss/dataverse' && '/Users/PDurbin/.sdkman/candidates/java/17.0.11-tem/bin/java' '${surefire.jacoco.args}' '-Duser.timezone=UTC' '-Dfile.encoding=UTF-8' '-Duser.language=en' '-Duser.region=US' '-jar' '/Users/PDurbin/github/iqss/dataverse/target/surefire/surefirebooter-20240726103630388_3.jar' '/Users/PDurbin/github/iqss/dataverse/target/surefire' '2024-07-26T10-36-30_347-jvmRun1' 'surefire-20240726103630388_1tmp' 'surefire_0-20240726103630388_2tmp'
Error occurred in starting fork, check output in log
Process Exit Code: 1
org.apache.maven.surefire.booter.SurefireBooterForkException: The forked VM terminated without properly saying goodbye. VM crash or System.exit called?
Command was /bin/sh -c cd '/Users/PDurbin/github/iqss/dataverse' && '/Users/PDurbin/.sdkman/candidates/java/17.0.11-tem/bin/java' '${surefire.jacoco.args}' '-Duser.timezone=UTC' '-Dfile.encoding=UTF-8' '-Duser.language=en' '-Duser.region=US' '-jar' '/Users/PDurbin/github/iqss/dataverse/target/surefire/surefirebooter-20240726103630388_3.jar' '/Users/PDurbin/github/iqss/dataverse/target/surefire' '2024-07-26T10-36-30_347-jvmRun1' 'surefire-20240726103630388_1tmp' 'surefire_0-20240726103630388_2tmp'
Error occurred in starting fork, check output in log
Process Exit Code: 1
	at org.apache.maven.plugin.surefire.booterclient.ForkStarter.fork(ForkStarter.java:643)
	at org.apache.maven.plugin.surefire.booterclient.ForkStarter.run(ForkStarter.java:285)
	at org.apache.maven.plugin.surefire.booterclient.ForkStarter.run(ForkStarter.java:250)
	at org.apache.maven.plugin.surefire.AbstractSurefireMojo.executeProvider(AbstractSurefireMojo.java:1241)
	at org.apache.maven.plugin.surefire.AbstractSurefireMojo.executeAfterPreconditionsChecked(AbstractSurefireMojo.java:1090)
	at org.apache.maven.plugin.surefire.AbstractSurefireMojo.execute(AbstractSurefireMojo.java:910)
	at org.apache.maven.plugin.DefaultBuildPluginManager.executeMojo(DefaultBuildPluginManager.java:126)
	at org.apache.maven.lifecycle.internal.MojoExecutor.doExecute2(MojoExecutor.java:328)
	at org.apache.maven.lifecycle.internal.MojoExecutor.doExecute(MojoExecutor.java:316)
	at org.apache.maven.lifecycle.internal.MojoExecutor.execute(MojoExecutor.java:212)
	at org.apache.maven.lifecycle.internal.MojoExecutor.execute(MojoExecutor.java:174)
	at org.apache.maven.lifecycle.internal.MojoExecutor.access$000(MojoExecutor.java:75)
	at org.apache.maven.lifecycle.internal.MojoExecutor$1.run(MojoExecutor.java:162)
	at org.apache.maven.plugin.DefaultMojosExecutionStrategy.execute(DefaultMojosExecutionStrategy.java:39)
	at org.apache.maven.lifecycle.internal.MojoExecutor.execute(MojoExecutor.java:159)
	at org.apache.maven.lifecycle.internal.LifecycleModuleBuilder.buildProject(LifecycleModuleBuilder.java:105)
	at org.apache.maven.lifecycle.internal.LifecycleModuleBuilder.buildProject(LifecycleModuleBuilder.java:73)
	at org.apache.maven.lifecycle.internal.builder.singlethreaded.SingleThreadedBuilder.build(SingleThreadedBuilder.java:53)
	at org.apache.maven.lifecycle.internal.LifecycleStarter.execute(LifecycleStarter.java:118)
	at org.apache.maven.DefaultMaven.doExecute(DefaultMaven.java:261)
	at org.apache.maven.DefaultMaven.doExecute(DefaultMaven.java:173)
	at org.apache.maven.DefaultMaven.execute(DefaultMaven.java:101)
	at org.apache.maven.cli.MavenCli.execute(MavenCli.java:906)
	at org.apache.maven.cli.MavenCli.doMain(MavenCli.java:283)
	at org.apache.maven.cli.MavenCli.main(MavenCli.java:206)
	at java.base/jdk.internal.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
	at java.base/jdk.internal.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:77)
	at java.base/jdk.internal.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43)
	at java.base/java.lang.reflect.Method.invoke(Method.java:568)
	at org.codehaus.plexus.classworlds.launcher.Launcher.launchEnhanced(Launcher.java:283)
	at org.codehaus.plexus.classworlds.launcher.Launcher.launch(Launcher.java:226)
	at org.codehaus.plexus.classworlds.launcher.Launcher.mainWithExitCode(Launcher.java:407)
	at org.codehaus.plexus.classworlds.launcher.Launcher.main(Launcher.java:348)

-> [Help 1]

To see the full stack trace of the errors, re-run Maven with the -e switch.
Re-run Maven using the -X switch to enable full debug logging.

For more information about the errors and possible solutions, please read the following articles:
[Help 1] http://cwiki.apache.org/confluence/display/MAVEN/MojoExecutionException

As a workaround I've been running tests from the command line like this...

pdurbin@beamish dataverse % mvn test -Dtest=JsonUtilTest                                           
[INFO] Scanning for projects...
[INFO] 
[INFO] ----------------------< edu.harvard.iq:dataverse >----------------------
[INFO] Building dataverse 6.3
[INFO]   from pom.xml
[INFO] --------------------------------[ war ]---------------------------------
[INFO] 
[INFO] --- enforcer:3.3.0:enforce (general-reqs) @ dataverse ---
[INFO] Rule 0: org.apache.maven.enforcer.rules.BanDuplicatePomDependencyVersions passed
[INFO] Rule 1: org.apache.maven.enforcer.rules.version.RequireJavaVersion passed
[INFO] 
[INFO] --- jacoco:0.8.11:prepare-agent (jacoco-initialize) @ dataverse ---
[INFO] surefire.jacoco.args set to -javaagent:/Users/PDurbin/.m2/repository/org/jacoco/org.jacoco.agent/0.8.11/org.jacoco.agent-0.8.11-runtime.jar=destfile=/Users/PDurbin/github/iqss/dataverse/target/coverage-reports/jacoco-unit.exec,includes=edu/harvard/iq/dataverse/*:io/gdcc/*:org/dataverse/*
[INFO] 
[INFO] --- resources:3.3.1:resources (default-resources) @ dataverse ---
[INFO] Copying 35 resources from src/main/java to target/classes
[INFO] Copying 85 resources from src/main/resources to target/classes
[INFO] Copying 2 resources from src/main/resources to target/classes
[INFO] The encoding used to copy filtered properties files have not been set. This means that the same encoding will be used to copy filtered properties files as when copying other filtered resources. This might not be what you want! Run your build with --debug to see which files might be affected. Read more at https://maven.apache.org/plugins/maven-resources-plugin/examples/filtering-properties-files.html
[INFO] 
[INFO] --- compiler:3.11.0:compile (default-compile) @ dataverse ---
[INFO] Nothing to compile - all classes are up to date
[INFO] 
[INFO] --- smallrye-open-api:3.10.0:generate-schema (default) @ dataverse ---
[INFO] Wrote the schema files to /Users/PDurbin/github/iqss/dataverse/target/classes/META-INF
[INFO] 
[INFO] --- enforcer:3.3.0:enforce (no-junit4) @ dataverse ---
[INFO] Rule 0: org.apache.maven.enforcer.rules.dependency.BannedDependencies passed
[INFO] 
[INFO] --- resources:3.3.1:testResources (default-testResources) @ dataverse ---
[INFO] Copying 87 resources from src/test/resources to target/test-classes
[INFO] Copying 5 resources from conf/keycloak to target/test-classes/keycloak
[INFO] 
[INFO] --- compiler:3.11.0:testCompile (default-testCompile) @ dataverse ---
[INFO] Nothing to compile - all classes are up to date
[INFO] 
[INFO] --- surefire:3.2.5:test (default-test) @ dataverse ---
[INFO] Using auto detected provider org.apache.maven.surefire.junitplatform.JUnitPlatformProvider
[INFO] 
[INFO] -------------------------------------------------------
[INFO]  T E S T S
[INFO] -------------------------------------------------------
[INFO] Running edu.harvard.iq.dataverse.util.json.JsonUtilTest
Jul 26, 2024 2:32:39 PM edu.harvard.iq.dataverse.util.json.JsonUtil prettyPrint
INFO: Returning original string due to exception: java.lang.NullPointerException: Cannot invoke "String.trim()" because "jsonString" is null
Jul 26, 2024 2:32:39 PM edu.harvard.iq.dataverse.util.json.JsonUtil prettyPrint
INFO: Returning original string due to exception: jakarta.json.stream.JsonParsingException: Invalid token=EOF at (line no=1, column no=0, offset=-1). Expected tokens are: [CURLYOPEN, SQUAREOPEN, STRING, NUMBER, TRUE, FALSE, NULL]
Jul 26, 2024 2:32:39 PM edu.harvard.iq.dataverse.util.json.JsonUtil prettyPrint
INFO: Returning original string due to exception: jakarta.json.stream.JsonParsingException: Unexpected char 106 at (line no=1, column no=1, offset=0)
[INFO] Tests run: 1, Failures: 0, Errors: 0, Skipped: 0, Time elapsed: 0.044 s -- in edu.harvard.iq.dataverse.util.json.JsonUtilTest
[INFO] 
[INFO] Results:
[INFO] 
[INFO] Tests run: 1, Failures: 0, Errors: 0, Skipped: 0
[INFO] 
[INFO] 
[INFO] --- jacoco:0.8.11:report (jacoco-after-unit) @ dataverse ---
[INFO] Loading execution data file /Users/PDurbin/github/iqss/dataverse/target/coverage-reports/jacoco-unit.exec
[INFO] Analyzed bundle 'dataverse' with 1047 classes
[WARNING] Classes in bundle 'dataverse' do not match with execution data. For report generation the same class files must be used as at runtime.
[WARNING] Execution data for class edu/harvard/iq/dataverse/api/Dataverses does not match.
[WARNING] Execution data for class edu/harvard/iq/dataverse/util/json/JsonParser does not match.
[INFO] ------------------------------------------------------------------------
[INFO] BUILD SUCCESS
[INFO] ------------------------------------------------------------------------
[INFO] Total time:  4.183 s
[INFO] Finished at: 2024-07-26T10:32:40-04:00
[INFO] ------------------------------------------------------------------------
pdurbin@beamish dataverse % 

... but it would be much more convenient to be able to run test from Netbeans again, as discussed in Slack.

Contributor guide

Open the contributing guide

First steps

  1. Read the whole issue, then the project's contributing guide.
  2. Comment on the issue to say you are picking it up — it saves two people doing the same work.
  3. Fork the repository and make your change on a branch.
  4. Open a pull request that references the issue number.

Research direction

Start with pom.xml and compare the JaCoCo prepare-agent setting for surefire.jacoco.args with the Maven command NetBeans runs for Test File. Reproduce the failure with edu.harvard.iq.dataverse.util.json.JsonUtilTest, then verify that the NetBeans test action runs the test successfully and produces the expected result.

Written by the indexing model from the issue text.

Assessment

Tech stack
java
Domain
build-system, developer-experience, testing
Issue type
Bug
Difficulty
3/5
Estimated time
1-2 days
Activity status
Stale
Clarity
Mostly clear
Newbie friendliness
35/100

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.