diff --git a/src/main/java/org/utplsql/cli/reporters/LocalAssetsCoverageHTMLReporter.java b/src/main/java/org/utplsql/cli/reporters/LocalAssetsCoverageHTMLReporter.java index a61d41a..330d2cc 100644 --- a/src/main/java/org/utplsql/cli/reporters/LocalAssetsCoverageHTMLReporter.java +++ b/src/main/java/org/utplsql/cli/reporters/LocalAssetsCoverageHTMLReporter.java @@ -6,6 +6,7 @@ import org.utplsql.api.reporter.ReporterFactory; import org.utplsql.cli.ReporterOptions; +import java.nio.file.Path; import java.nio.file.Paths; import java.sql.Connection; import java.sql.SQLException; @@ -27,15 +28,34 @@ public LocalAssetsCoverageHTMLReporter(String selfType, Object[] attributes) { public Reporter init(Connection con, CompatibilityProxy compatibilityProxy, ReporterFactory reporterFactory) throws SQLException { super.init(con, compatibilityProxy, reporterFactory); - if ( options != null && options.outputToFile() ) - writeReportAssetsTo(Paths.get(getAssetsPath())); + if ( hasOutputToFile() ) { + writeReportAssetsTo(getPhysicalAssetPath()); + } return this; } + private String getNameOfOutputFile() { + Path outputPath = Paths.get(options.getOutputFileName()); + return outputPath.getName(outputPath.getNameCount()-1).toString(); + } + + private Path getPhysicalAssetPath() { + Path outputPath = Paths.get(options.getOutputFileName()); + if ( outputPath.getNameCount() > 1 ) + return outputPath.getParent().resolve(getAssetsPath()); + else + return Paths.get(getAssetsPath()); + } + private void setAssetsPathFromOptions() { - if ( options != null && options.outputToFile() ) - setAssetsPath(options.getOutputFileName()+"_assets/"); + if ( hasOutputToFile() ) { + setAssetsPath(getNameOfOutputFile() + "_assets/"); + } + } + + private boolean hasOutputToFile() { + return (options != null && options.outputToFile()); } @Override diff --git a/src/test/java/org/utplsql/cli/RunCommandCoverageReporterIT.java b/src/test/java/org/utplsql/cli/RunCommandCoverageReporterIT.java index 1b0fa36..a8cd82d 100644 --- a/src/test/java/org/utplsql/cli/RunCommandCoverageReporterIT.java +++ b/src/test/java/org/utplsql/cli/RunCommandCoverageReporterIT.java @@ -109,4 +109,26 @@ public void coverageReporterWriteAssetsToOutput() throws Exception { assertTrue(content.contains("