Skip to content

Commit

Permalink
resolve #2633
Browse files Browse the repository at this point in the history
  • Loading branch information
ptrthomas committed Jan 3, 2025
1 parent 849b05a commit 28ce176
Show file tree
Hide file tree
Showing 2 changed files with 16 additions and 1 deletion.
10 changes: 9 additions & 1 deletion karate-core/src/main/java/com/intuit/karate/Main.java
Original file line number Diff line number Diff line change
Expand Up @@ -94,7 +94,7 @@ public class Main implements Callable<Void> {
@Option(names = {"-T", "--threads"}, description = "number of threads when running tests")
int threads;

@Option(names = {"-o", "--output"}, description = "directory where logs and reports are output (default 'target')")
@Option(names = {"-o", "--output"}, description = "directory where logs and report sub-folders are output (default 'target')")
String output = FileUtils.getBuildDir();

@Option(names = {"-f", "--format"}, split = ",", description = "comma separate report output formats. tilde excludes the output report. html report is included by default unless it's negated."
Expand All @@ -113,6 +113,9 @@ public class Main implements Callable<Void> {
@Option(names = {"-g", "--configdir"}, description = "directory where 'karate-config.js' is expected (default 'classpath:' or <workingdir>)")
String configDir;

@Option(names = {"-r", "--reportdir"}, description = "directory where Karate HTML and JSON reports are placed (default '<output>/karate-reports')")
String reportDir;

@Option(names = {"-C", "--clean"}, description = "clean output directory")
boolean clean;

Expand Down Expand Up @@ -194,6 +197,10 @@ public void setConfigDir(String configDir) {
this.configDir = configDir;
}

public String getReportDir() {
return reportDir;
}

public static Main parseKarateOptions(String line) {
String[] args = Command.tokenize(line);
return CommandLine.populateCommand(new Main(), args);
Expand Down Expand Up @@ -328,6 +335,7 @@ public Void call() throws Exception {
.buildDir(output)
.backupReportDir(backupReportDir)
.configDir(configDir)
.reportDir(reportDir)
.outputHtmlReport(isOutputHtmlReport())
.outputCucumberJson(isOutputCucumberJson())
.outputJunitXml(isOutputJunitXml())
Expand Down
7 changes: 7 additions & 0 deletions karate-core/src/main/java/com/intuit/karate/Runner.java
Original file line number Diff line number Diff line change
Expand Up @@ -173,6 +173,9 @@ public List<FeatureCall> resolveAll() {
if (tempOptions != null) {
LOGGER.info("using system property '{}': {}", Constants.KARATE_OPTIONS, tempOptions);
Main ko = Main.parseKarateOptions(tempOptions);
if (ko.reportDir != null) {
reportDir = ko.reportDir;
}
if (ko.tags != null) {
tags = ko.tags;
}
Expand Down Expand Up @@ -483,6 +486,10 @@ private String[] getDebugArgs(int debugPort) {
List<String> args = new ArrayList();
args.add("-d");
args.add(debugPort + "");
if (reportDir != null) {
args.add("-r");
args.add(reportDir);
}
if (env != null) {
args.add("-e");
args.add(env);
Expand Down

0 comments on commit 28ce176

Please sign in to comment.