Skip to content

Commit

Permalink
refactor: Update JUnitTestFileGenerator to use relative path for TEST…
Browse files Browse the repository at this point in the history
…_REPORT_FILE

This commit updates the JUnitTestFileGenerator class to use a relative path for the TEST_REPORT_FILE constant. Instead of directly referencing the exportPath, the code now uses the System.getProperty("user.dir") to get the current working directory and constructs the relative path to the testReport.csv file. This change ensures that the TEST_REPORT_FILE is always correctly resolved, regardless of the location of the project.
  • Loading branch information
remiceres committed Jul 1, 2024
1 parent d941bf8 commit 8545824
Show file tree
Hide file tree
Showing 2 changed files with 10 additions and 4 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@
import java.net.URI;
import java.nio.file.Files;
import java.nio.file.Path;
import java.nio.file.Paths;
import java.time.LocalDate;
import java.time.ZonedDateTime;
import java.time.format.DateTimeFormatter;
Expand Down Expand Up @@ -185,8 +186,13 @@ private String generateWatcher() {
StringBuilder watcher = new StringBuilder();

// Create a file testReport.csv in the directory of the test file
watcher.append(" private static final String TEST_REPORT_FILE = \""
+ this.exportPath.resolve("testReport.csv") + "\";\n");
Path relativePathToResultCsv = Paths.get(System.getProperty("user.dir")).relativize(exportPath)
.resolve("testReport.csv");
// Remove the first directory from the path
relativePathToResultCsv = relativePathToResultCsv.subpath(1, relativePathToResultCsv.getNameCount());
watcher.append(" private static final String TEST_REPORT_FILE = "
+ "Paths.get(System.getProperty(\"user.dir\")).resolve(\"" + relativePathToResultCsv.toString()
+ "\").toString();\n");
watcher.append(" private static final String MANIFEST_URI = \""
+ manifestUri.toString().substring(0, manifestUri.toString().lastIndexOf(".")) + "\";\n");
watcher.append(" private static final String EARL = \"http://www.w3.org/ns/earl#\";\n");
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -30,11 +30,11 @@
/**
* Auto-generated JUnit test file for the W3C test suite: https://w3c.github.io/rdf-canon/tests/manifest.ttl
* This file was automatically generated by JUnitTestFileGenerator.java.
* Generation date: 2024-04-11, Time: 16:06:27 Europe/Paris
* Generation date: 2024-07-01, Time: 19:20:37 Europe/Paris
*/
public class canonicalRdfTest {

private static final String TEST_REPORT_FILE = "/home/rceres/Documents/projects/Corese/code/corese/corese-unit-test/src/test/java/fr/inria/corese/w3c/canonicalRdf/testReport.csv";
private static final String TEST_REPORT_FILE = Paths.get(System.getProperty("user.dir")).resolve("src/test/java/fr/inria/corese/w3c/canonicalRdf/testReport.csv").toString();
private static final String MANIFEST_URI = "https://w3c.github.io/rdf-canon/tests/manifest";
private static final String EARL = "http://www.w3.org/ns/earl#";

Expand Down

0 comments on commit 8545824

Please sign in to comment.