Skip to content

Commit 28ce176

Browse files
committed
resolve #2633
1 parent 849b05a commit 28ce176

File tree

2 files changed

+16
-1
lines changed

2 files changed

+16
-1
lines changed

karate-core/src/main/java/com/intuit/karate/Main.java

+9-1
Original file line numberDiff line numberDiff line change
@@ -94,7 +94,7 @@ public class Main implements Callable<Void> {
9494
@Option(names = {"-T", "--threads"}, description = "number of threads when running tests")
9595
int threads;
9696

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

100100
@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."
@@ -113,6 +113,9 @@ public class Main implements Callable<Void> {
113113
@Option(names = {"-g", "--configdir"}, description = "directory where 'karate-config.js' is expected (default 'classpath:' or <workingdir>)")
114114
String configDir;
115115

116+
@Option(names = {"-r", "--reportdir"}, description = "directory where Karate HTML and JSON reports are placed (default '<output>/karate-reports')")
117+
String reportDir;
118+
116119
@Option(names = {"-C", "--clean"}, description = "clean output directory")
117120
boolean clean;
118121

@@ -194,6 +197,10 @@ public void setConfigDir(String configDir) {
194197
this.configDir = configDir;
195198
}
196199

200+
public String getReportDir() {
201+
return reportDir;
202+
}
203+
197204
public static Main parseKarateOptions(String line) {
198205
String[] args = Command.tokenize(line);
199206
return CommandLine.populateCommand(new Main(), args);
@@ -328,6 +335,7 @@ public Void call() throws Exception {
328335
.buildDir(output)
329336
.backupReportDir(backupReportDir)
330337
.configDir(configDir)
338+
.reportDir(reportDir)
331339
.outputHtmlReport(isOutputHtmlReport())
332340
.outputCucumberJson(isOutputCucumberJson())
333341
.outputJunitXml(isOutputJunitXml())

karate-core/src/main/java/com/intuit/karate/Runner.java

+7
Original file line numberDiff line numberDiff line change
@@ -173,6 +173,9 @@ public List<FeatureCall> resolveAll() {
173173
if (tempOptions != null) {
174174
LOGGER.info("using system property '{}': {}", Constants.KARATE_OPTIONS, tempOptions);
175175
Main ko = Main.parseKarateOptions(tempOptions);
176+
if (ko.reportDir != null) {
177+
reportDir = ko.reportDir;
178+
}
176179
if (ko.tags != null) {
177180
tags = ko.tags;
178181
}
@@ -483,6 +486,10 @@ private String[] getDebugArgs(int debugPort) {
483486
List<String> args = new ArrayList();
484487
args.add("-d");
485488
args.add(debugPort + "");
489+
if (reportDir != null) {
490+
args.add("-r");
491+
args.add(reportDir);
492+
}
486493
if (env != null) {
487494
args.add("-e");
488495
args.add(env);

0 commit comments

Comments
 (0)