esapi-java-legacy
esapi-java-legacy copied to clipboard
Apply Surefire JVM Isolation to Maven Test execution
Discussed in the scope of release 2.2.3.0, we're looking to update the project to remove forks from the surefire test execution environment. Doing this should remove some scale of cross-contamination of static project state across the tests, and further ensure that tests may run both as independent units as well as through the overall project execution. Expectations at the end of this effort:
- Surefire configuration is updated to remove forking
- When run as a collective unit, all tests are successful through a full maven test cycle.
- When run as an independent unit, each test is successful through the maven test phase.
IDE behavior is preferred, and should be tested for issues. Minimally, the common maven behavior must be provided.
To update the Surefire configuration:
<build>
<pluginManagement>
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-surefire-plugin</artifactId>
<version>${version.surefire}</version>
<configuration>
<forkCount>0</forkCount>
<reuseForks>false</reuseForks>
</configuration>
</plugin>
</pluginManagement>
</build>
Applying this setting current causes a number of test errors. Addressing the errors is expected be the majority of the work related to this task.
Is there a way to essentially tell an individual JUnit test class (or ideally method) to behave as though
<configuration>
<forkCount>0</forkCount>
<reuseForks>false</reuseForks>
</configuration>
is set, possibly via a JUnit annotation or something? Because that would allow us to approach this one test at a time.
I suppose we could also specify an alternate pom.xml, e.g., "no-reuse-fork-pom.xml" that we use when running manual and allow the GitHub CI workflow to continue to use pom.xml.