The presence of an HKEY_CURRENT_USER\Software\Microsoft\Command Processor\Autorun causes a java test to fail. Github repo to test this out : https://github.com/ajorpheus/final-frontier
This is a follow-up question after this happened.
Summary : Apparently a registry hack which allows a command to be run every time the cmd prompt is opened, adversely affects the Java process.
To begin with I thought, that perhaps it was the fact that 'mvn clean test' actually resolves to 'mvn.bat clean test'. However, I tried extracting the java.exe command contained in the mvn.bat file and tried using that directly, but got the same issue.
Any thoughts about why this might be happening ?
Update
Value of the Autorun entry is : cd /d "c:\dev"
Error message is as follows:
java.lang.RuntimeException: Error writing to file: some-dir/target/generated-resources/stuff.xmlwith the following error: Couldn't create dir: some-dir\target\generated-resources at com.test.build.TestFileCreation.createDirectoryTest
Update2
As @NilsH suggested, I've confirmed that the current working directory in both the cases is the same.
Update3
Added a maven profile which sets maven-surefire-plugin's forkMode to never. This profile causes the test to pass irrespective of whether the registry hack is there or not.