Thanks to visit codestin.com
Credit goes to github.com

Skip to content
Merged
Show file tree
Hide file tree
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Prev Previous commit
Next Next commit
First simple implementation of copying necessary assets
Needs lots of refactoring
  • Loading branch information
Samuel Nitsche committed Feb 7, 2018
commit 8f4a7e1b9a0e7b6ea98576ce9798b30209d3ce68
11 changes: 9 additions & 2 deletions src/main/java/org/utplsql/cli/RunCommand.java
Original file line number Diff line number Diff line change
Expand Up @@ -4,9 +4,8 @@
import com.beust.jcommander.Parameters;
import org.utplsql.api.*;
import org.utplsql.api.compatibility.CompatibilityProxy;
import org.utplsql.api.compatibility.OptionalFeatures;
import org.utplsql.api.exception.DatabaseNotCompatibleException;
import org.utplsql.api.exception.SomeTestsFailedException;
import org.utplsql.api.reporter.CoverageHTMLReporter;
import org.utplsql.api.reporter.Reporter;
import org.utplsql.api.reporter.ReporterFactory;
import org.utplsql.cli.exception.DatabaseConnectionFailed;
Expand All @@ -15,6 +14,7 @@
import java.io.FileNotFoundException;
import java.io.FileOutputStream;
import java.io.PrintStream;
import java.nio.file.Paths;
import java.sql.Connection;
import java.sql.SQLException;
import java.util.ArrayList;
Expand Down Expand Up @@ -219,6 +219,13 @@ private List<Reporter> initReporters( Connection conn, List<ReporterOptions> rep

for (ReporterOptions ro : reporterOptionsList) {
Reporter reporter = ReporterFactory.createReporter(ro.getReporterName());

// Quick-hack for CoverageHTML Reporter
if ( reporter instanceof CoverageHTMLReporter && ro.outputToFile() ) {
((CoverageHTMLReporter)reporter).setAssetsPath(ro.getOutputFileName()+"_assets/");
CoverageHTMLReporter.writeReportAssetsTo(Paths.get(ro.getOutputFileName()+"_assets/"));
}

reporter.init(conn);
ro.setReporterObj(reporter);
reporterList.add(reporter);
Expand Down
24 changes: 24 additions & 0 deletions src/test/java/org/utplsql/cli/RunCommandCoverageReporterIT.java
Original file line number Diff line number Diff line change
Expand Up @@ -2,14 +2,17 @@

import org.junit.jupiter.api.Test;

import java.io.File;
import java.nio.file.Files;
import java.nio.file.Path;
import java.nio.file.Paths;
import java.util.List;
import java.util.Scanner;
import java.util.regex.Matcher;
import java.util.regex.Pattern;

import static org.junit.jupiter.api.Assertions.assertEquals;
import static org.junit.jupiter.api.Assertions.assertTrue;

/**
* System tests for Code Coverage Reporter
Expand Down Expand Up @@ -83,4 +86,25 @@ public void run_CodeCoverageWithIncludeAndExclude() throws Exception {
}

}

@Test
public void coverageReporterWriteAssetsToOutput() throws Exception {
Path coveragePath = getTempCoverageFilePath();

RunCommand runCmd = RunCommandTestHelper.createRunCommand(RunCommandTestHelper.getConnectionString(),
"-f=ut_coverage_html_reporter", "-o=" + coveragePath, "-s");
try {
int result = runCmd.run();

List<ReporterOptions> reporterOptions = runCmd.getReporterOptionsList();
File applicationJs = coveragePath.resolve(Paths.get("assets", "application.js")).toFile();

assertTrue(applicationJs.exists());

} finally {
if ( Files.exists(coveragePath))
Files.delete(coveragePath);
}

}
}