Details
-
Bug
-
Status: Closed
-
Minor
-
Resolution: Fixed
-
3.2.1, 3.3.1, 3.3.9
-
None
-
None
-
Windows 10 x64
Tested in cmd.exe, git bash.
Description
I set up a very simple test maven project with only a dependency to testNG.
public class TestTest { @Test public void test() { System.out.println(getClass().getResource("/"));
Depending on how I build this, the call either returns null or the expected directory. How is that?
// Prints: file:/C:/workspace/test/testproject/target/test-classes/ mvn clean test -Dtest=TestTest -f pom.xml // Prints: file:/C:/workspace/test/testproject/target/test-classes/ mvn clean test -Dtest=TestTest -f testproject/pom.xml // Prints: null mvn clean test -Dtest=TestTest -f ./pom.xml // Prints: null mvn clean test -Dtest=TestTest -f ./testproject/pom.xml
Note that the second call includes "./" after -f.
I actually want to find out the /target folder regardless of scenario (testNG in IntelliJ, Maven, Jenkins Buid, ...). So far, this way has proven the most reliable.
System.out.println(getClass().getResource("./"));
This seems to reliably point to file:/C:/workspace/test/testproject/target/test-classes/com/testproject/test. Would this be safer to use?
Attachments
Issue Links
- is related to
-
MNG-6444 Internal code should prefer Path over File
- Open
- links to