How to use reportDir method of com.intuit.karate.Runner class

Best Karate code snippet using com.intuit.karate.Runner.reportDir

Source:Runner.java Github

copy

Full Screen

...61 public static class Builder {62 Class optionsClass;63 int threadCount;64 int timeoutMinutes;65 String reportDir;66 String scenarioName;67 List<String> tags = new ArrayList();68 List<String> paths = new ArrayList();69 List<Resource> resources;70 Collection<ExecutionHook> hooks;71 ExecutionHookFactory hookFactory;72 JobConfig jobConfig;73 String tagSelector() {74 return Tags.fromKarateOptionsTags(tags);75 }76 List<Resource> resolveResources() {77 RunnerOptions options = RunnerOptions.fromAnnotationAndSystemProperties(paths, tags, optionsClass);78 paths = options.features;79 tags = options.tags;80 if (scenarioName == null) { // this could have been set by cli (e.g. intellij) so preserve if needed81 scenarioName = options.name;82 }83 if (resources == null) {84 return FileUtils.scanForFeatureFiles(paths, Thread.currentThread().getContextClassLoader());85 }86 return resources;87 }88 String resolveReportDir() {89 if (reportDir == null) {90 reportDir = FileUtils.getBuildDir() + File.separator + ScriptBindings.SUREFIRE_REPORTS;91 }92 new File(reportDir).mkdirs();93 return reportDir;94 }95 JobServer jobServer() {96 return jobConfig == null ? null : new ScenarioJobServer(jobConfig, reportDir);97 }98 int resolveThreadCount() {99 if (threadCount < 1) {100 threadCount = 1;101 }102 return threadCount;103 }104 //======================================================================105 //106 public Builder path(String... paths) {107 this.paths.addAll(Arrays.asList(paths));108 return this;109 }110 public Builder path(List<String> paths) {111 if (paths != null) {112 this.paths.addAll(paths);113 }114 return this;115 }116 public Builder tags(List<String> tags) {117 if (tags != null) {118 this.tags.addAll(tags);119 }120 return this;121 }122 public Builder tags(String... tags) {123 this.tags.addAll(Arrays.asList(tags));124 return this;125 }126 public Builder resources(Collection<Resource> resources) {127 if (resources != null) {128 if (this.resources == null) {129 this.resources = new ArrayList();130 }131 this.resources.addAll(resources);132 }133 return this;134 }135 public Builder resources(Resource... resources) {136 return resources(Arrays.asList(resources));137 }138 public Builder forClass(Class clazz) {139 this.optionsClass = clazz;140 return this;141 }142 public Builder reportDir(String dir) {143 this.reportDir = dir;144 return this;145 }146 public Builder scenarioName(String name) {147 this.scenarioName = name;148 return this;149 }150 public Builder timeoutMinutes(int timeoutMinutes) {151 this.timeoutMinutes = timeoutMinutes;152 return this;153 }154 public Builder hook(ExecutionHook hook) {155 if (hooks == null) {156 hooks = new ArrayList();157 }158 hooks.add(hook);159 return this;160 }161 public Builder hookFactory(ExecutionHookFactory hookFactory) {162 this.hookFactory = hookFactory;163 return this;164 }165 public Results parallel(int threadCount) {166 this.threadCount = threadCount;167 return Runner.parallel(this);168 }169 public Results startServerAndWait(JobConfig config) {170 this.jobConfig = config;171 this.threadCount = 1;172 return Runner.parallel(this);173 }174 }175 public static Builder path(String... paths) {176 Builder builder = new Builder();177 return builder.path(paths);178 }179 public static Builder path(List<String> paths) {180 Builder builder = new Builder();181 return builder.path(paths);182 }183 //==========================================================================184 //185 public static Results parallel(Class<?> clazz, int threadCount) {186 return parallel(clazz, threadCount, null);187 }188 public static Results parallel(Class<?> clazz, int threadCount, String reportDir) {189 return new Builder().forClass(clazz).reportDir(reportDir).parallel(threadCount);190 }191 public static Results parallel(List<String> tags, List<String> paths, int threadCount, String reportDir) {192 return parallel(tags, paths, null, null, threadCount, reportDir);193 }194 public static Results parallel(int threadCount, String... tagsOrPaths) {195 return parallel(null, threadCount, tagsOrPaths);196 }197 public static Results parallel(String reportDir, int threadCount, String... tagsOrPaths) {198 List<String> tags = new ArrayList();199 List<String> paths = new ArrayList();200 for (String s : tagsOrPaths) {201 s = StringUtils.trimToEmpty(s);202 if (s.startsWith("~") || s.startsWith("@")) {203 tags.add(s);204 } else {205 paths.add(s);206 }207 }208 return parallel(tags, paths, threadCount, reportDir);209 }210 public static Results parallel(List<String> tags, List<String> paths, String scenarioName,211 List<ExecutionHook> hooks, int threadCount, String reportDir) {212 Builder options = new Builder();213 options.tags = tags;214 options.paths = paths;215 options.scenarioName = scenarioName;216 options.hooks = hooks;217 options.reportDir = reportDir;218 return options.parallel(threadCount);219 }220 public static Results parallel(List<Resource> resources, int threadCount, String reportDir) {221 Builder options = new Builder();222 options.resources = resources;223 options.reportDir = reportDir;224 return options.parallel(threadCount);225 }226 private static void onFeatureDone(Results results, ExecutionContext execContext, String reportDir, int index, int count) {227 FeatureResult result = execContext.result;228 Feature feature = execContext.featureContext.feature;229 if (result.getScenarioCount() > 0) { // possible that zero scenarios matched tags230 try { // edge case that reports are not writable231 File file = Engine.saveResultJson(reportDir, result, null);232 if (result.getScenarioCount() < 500) {233 // TODO this routine simply cannot handle that size234 Engine.saveResultXml(reportDir, result, null);235 }236 String status = result.isFailed() ? "fail" : "pass";237 LOGGER.info("<<{}>> feature {} of {}: {}", status, index, count, feature.getRelativePath());238 result.printStats(file.getPath());239 } catch (Exception e) {240 LOGGER.error("<<error>> unable to write report file(s): {}", e.getMessage());241 result.printStats(null);242 }243 } else {244 results.addToSkipCount(1);245 if (LOGGER.isTraceEnabled()) {246 LOGGER.trace("<<skip>> feature {} of {}: {}", index, count, feature.getRelativePath());247 }248 }249 }250 public static Results parallel(Builder options) {251 String reportDir = options.resolveReportDir();252 // order matters, server depends on reportDir resolution253 JobServer jobServer = options.jobServer();254 int threadCount = options.resolveThreadCount();255 Results results = Results.startTimer(threadCount);256 results.setReportDir(reportDir);257 if (options.hooks != null) {258 options.hooks.forEach(h -> h.beforeAll(results));259 }260 ExecutorService featureExecutor = Executors.newFixedThreadPool(threadCount, Executors.privilegedThreadFactory());261 ExecutorService scenarioExecutor = Executors.newWorkStealingPool(threadCount);262 List<Resource> resources = options.resolveResources();263 try {264 int count = resources.size();265 CountDownLatch latch = new CountDownLatch(count);266 List<FeatureResult> featureResults = new ArrayList(count);267 for (int i = 0; i < count; i++) {268 Resource resource = resources.get(i);269 int index = i + 1;270 Feature feature = FeatureParser.parse(resource);271 feature.setCallName(options.scenarioName);272 feature.setCallLine(resource.getLine());273 FeatureContext featureContext = new FeatureContext(null, feature, options.tagSelector());274 CallContext callContext = CallContext.forAsync(feature, options.hooks, options.hookFactory, null, false);275 ExecutionContext execContext = new ExecutionContext(results, results.getStartTime(), featureContext, callContext, reportDir,276 r -> featureExecutor.submit(r), scenarioExecutor, Thread.currentThread().getContextClassLoader());277 featureResults.add(execContext.result);278 if (jobServer != null) {279 List<ScenarioExecutionUnit> units = feature.getScenarioExecutionUnits(execContext);280 jobServer.addFeature(execContext, units, () -> {281 onFeatureDone(results, execContext, reportDir, index, count);282 latch.countDown();283 });284 } else {285 FeatureExecutionUnit unit = new FeatureExecutionUnit(execContext);286 unit.setNext(() -> {287 onFeatureDone(results, execContext, reportDir, index, count);288 latch.countDown();289 });290 featureExecutor.submit(unit);291 }292 }293 if (jobServer != null) {294 jobServer.startExecutors();295 }296 LOGGER.info("waiting for parallel features to complete ...");297 if (options.timeoutMinutes > 0) {298 latch.await(options.timeoutMinutes, TimeUnit.MINUTES);299 if (latch.getCount() > 0) {300 LOGGER.warn("parallel execution timed out after {} minutes, features remaining: {}",301 options.timeoutMinutes, latch.getCount());302 }303 } else {304 latch.await();305 }306 results.stopTimer();307 HtmlSummaryReport summary = new HtmlSummaryReport();308 for (FeatureResult result : featureResults) {309 int scenarioCount = result.getScenarioCount();310 results.addToScenarioCount(scenarioCount);311 if (scenarioCount != 0) {312 results.incrementFeatureCount();313 }314 results.addToFailCount(result.getFailedCount());315 results.addToTimeTaken(result.getDurationMillis());316 if (result.isFailed()) {317 results.addToFailedList(result.getPackageQualifiedName(), result.getErrorMessages());318 }319 results.addScenarioResults(result.getScenarioResults());320 if (!result.isEmpty()) {321 HtmlFeatureReport.saveFeatureResult(reportDir, result);322 summary.addFeatureResult(result);323 }324 }325 // saving reports can in rare cases throw errors, so do within try block326 summary.save(reportDir);327 results.printStats(threadCount);328 Engine.saveStatsJson(reportDir, results);329 HtmlReport.saveTimeline(reportDir, results, null);330 if (options.hooks != null) {331 options.hooks.forEach(h -> h.afterAll(results));332 }333 } catch (Exception e) {334 LOGGER.error("karate parallel runner failed: ", e.getMessage());335 results.setFailureReason(e);336 } finally {337 featureExecutor.shutdownNow();338 scenarioExecutor.shutdownNow();339 }340 return results;341 }342 public static Map<String, Object> runFeature(Feature feature, Map<String, Object> vars, boolean evalKarateConfig) {343 CallContext callContext = new CallContext(vars, evalKarateConfig);...

Full Screen

Full Screen

Source:CucumberRunner.java Github

copy

Full Screen

...42 private static final Logger logger = LoggerFactory.getLogger(CucumberRunner.class);43 public static KarateStats parallel(Class<?> clazz, int threadCount) {44 return parallel(clazz, threadCount, null);45 }46 public static KarateStats parallel(Class<?> clazz, int threadCount, String reportDir) {47 return new KarateStats(Runner.parallel(clazz, threadCount, reportDir));48 } 49 50 public static KarateStats parallel(List<String> tags, List<String> paths, int threadCount, String reportDir) {51 return parallel(tags, paths, null, threadCount, reportDir);52 } 53 54 public static KarateStats parallel(List<String> tags, List<String> paths, Collection<ExecutionHook> hooks, int threadCount, String reportDir) {55 return new KarateStats(Runner.parallel(tags, paths, null, hooks, threadCount, reportDir));56 }57 58 public static KarateStats parallel(String tagSelector, List<Resource> resources, int threadCount, String reportDir) {59 return parallel(tagSelector, resources, null, threadCount, reportDir);60 } 61 62 public static KarateStats parallel(String tagSelector, List<Resource> resources, Collection<ExecutionHook> hooks, int threadCount, String reportDir) {63 return new KarateStats(Runner.parallel(tagSelector, resources, null, hooks, threadCount, reportDir));64 }65 public static Map<String, Object> runFeature(Feature feature, Map<String, Object> vars, boolean evalKarateConfig) {66 return Runner.runFeature(feature, vars, evalKarateConfig);67 }68 public static Map<String, Object> runFeature(File file, Map<String, Object> vars, boolean evalKarateConfig) {69 return Runner.runFeature(file, vars, evalKarateConfig);70 }71 public static Map<String, Object> runFeature(Class relativeTo, String path, Map<String, Object> vars, boolean evalKarateConfig) {72 return Runner.runFeature(relativeTo, path, vars, evalKarateConfig);73 }74 public static Map<String, Object> runFeature(String path, Map<String, Object> vars, boolean evalKarateConfig) {75 return Runner.runFeature(path, vars, evalKarateConfig);76 } 77 ...

Full Screen

Full Screen

reportDir

Using AI Code Generation

copy

Full Screen

1import com.intuit.karate.Runner;2import com.intuit.karate.Results;3import java.io.File;4import java.util.ArrayList;5import java.util.Collection;6import java.util.List;7public class 4 {8 public static void main(String[] args) {9 String karateOutputPath = "C:\\Users\\johndoe\\Desktop\\MyProject\\src\\test\\java\\com\\intuit\\karate\\demo";10 String reportPath = "C:\\Users\\johndoe\\Desktop\\MyProject\\src\\test\\java\\com\\intuit\\karate\\demo\\reports";11 String consolidatedReportPath = "C:\\Users\\johndoe\\Desktop\\MyProject\\src\\test\\java\\com\\intuit\\karate\\demo\\consolidatedReport";12 String consolidatedReportName = "MyProject";13 String consolidatedReportTitle = "MyProject";14 String consolidatedReportTheme = "dark";15 String consolidatedReportDateFormat = "yyyy-MM-dd";16 String consolidatedReportTimeFormat = "HH:mm:ss";17 String consolidatedReportReportName = "MyProject";18 String consolidatedReportReportHeadline = "MyProject";19 String consolidatedReportReportDescription = "MyProject";20 String consolidatedReportReportEncoding = "UTF-8";

Full Screen

Full Screen

reportDir

Using AI Code Generation

copy

Full Screen

1import com.intuit.karate.Runner;2import com.intuit.karate.Results;3import java.io.File;4import java.util.ArrayList;5import java.util.Collection;6import java.util.List;7import java.util.Map;8import java.util.HashMap;9import java.util.Arrays;10import java.util.Collections;11public class 4 {12 public static void main(String[] args) {13 String karateOutputPath = "target/surefire-reports";14 Results results = Runner.path("classpath:com/qa/karate").tags("~@ignore").parallel(5);15 generateReport(results.getReportDir());16 }17 public static void generateReport(String karateOutputPath) {18 Collection<File> jsonFiles = FileUtils.listFiles(new File(karateOutputPath), new String[] {"json"}, true);19 List<String> jsonPaths = new ArrayList(jsonFiles.size());20 jsonFiles.forEach(file -> jsonPaths.add(file.getAbsolutePath()));21 Configuration config = new Configuration(new File("target"), "demo");22 ReportBuilder reportBuilder = new ReportBuilder(jsonPaths, config);23 reportBuilder.generateReports();24 }25}26import com.intuit.karate.Runner;27import com.intuit.karate.Results;28import java.io.File;29import java.util.ArrayList;30import java.util.Collection;31import java.util.List;32import java.util.Map;33import java.util.HashMap;34import java.util.Arrays;35import java.util.Collections;36public class 5 {37 public static void main(String[] args) {38 String karateOutputPath = "target/surefire-reports";39 Results results = Runner.path("classpath:com/qa/karate").tags("~@ignore").parallel(5);40 generateReport(results.getReportDir());41 }42 public static void generateReport(String karateOutputPath) {43 Collection<File> jsonFiles = FileUtils.listFiles(new File(karateOutputPath), new String[] {"json"}, true);44 List<String> jsonPaths = new ArrayList(jsonFiles.size());45 jsonFiles.forEach(file -> jsonPaths.add(file.getAbsolutePath()));46 Configuration config = new Configuration(new File("target"), "demo");47 ReportBuilder reportBuilder = new ReportBuilder(jsonPaths, config);48 reportBuilder.generateReports();49 }50}

Full Screen

Full Screen

reportDir

Using AI Code Generation

copy

Full Screen

1import com.intuit.karate.Runner;2import java.io.File;3import java.util.ArrayList;4import java.util.Collection;5import java.util.List;6public class 4 {7 public static void main(String[] args) {8 String karateOutputPath = "target/surefire-reports";9 Runner.Builder builder = Runner.path("classpath:com/intuit/karate/demo").tags("~@ignore");10 Collection<String> jsonPaths = new ArrayList();11 builder.parallel(5);12 Runner runner = builder.build();13 runner.run();14 runner.generateReport(karateOutputPath);15 }16}

Full Screen

Full Screen

reportDir

Using AI Code Generation

copy

Full Screen

1package com.intuit.karate;2import java.io.File;3import java.util.ArrayList;4import java.util.Collection;5public class Runner {6 public static void main(String[] args) {7 String karateOutputPath = "target/surefire-reports";8 .getFileList("target/surefire-reports", ".json");9 ReportBuilder reportBuilder = new ReportBuilder(jsonFiles,10 karateOutputPath);11 reportBuilder.generateReports();12 }13}14package com.intuit.karate;15import java.io.File;16import java.util.ArrayList;17import java.util.Collection;18public class Runner {19 public static void main(String[] args) {20 String karateOutputPath = "target/surefire-reports";21 .getFileList("target/surefire-reports", ".json");22 ReportBuilder reportBuilder = new ReportBuilder(jsonFiles,23 karateOutputPath);24 reportBuilder.generateReports();25 }26}27package com.intuit.karate;28import java.io.File;29import java.util.ArrayList;30import java.util.Collection;31public class Runner {32 public static void main(String[] args) {33 String karateOutputPath = "target/surefire-reports";34 .getFileList("target/surefire-reports", ".json");35 ReportBuilder reportBuilder = new ReportBuilder(jsonFiles,36 karateOutputPath);37 reportBuilder.generateReports();38 }39}40package com.intuit.karate;41import java.io.File;42import java.util.ArrayList;43import java.util.Collection;44public class Runner {45 public static void main(String[] args) {46 String karateOutputPath = "target/surefire-reports";47 .getFileList("target/surefire-reports", ".json");48 ReportBuilder reportBuilder = new ReportBuilder(jsonFiles,49 karateOutputPath);50 reportBuilder.generateReports();51 }52}53package com.intuit.karate;54import java.io.File;55import java.util.ArrayList;56import java.util.Collection;57public class Runner {58 public static void main(String[] args) {59 String karateOutputPath = "target/surefire-reports";

Full Screen

Full Screen

reportDir

Using AI Code Generation

copy

Full Screen

1package com.intuit.karate;2import java.io.File;3public class 4 {4public static void main(String[] args) {5File file = Runner.reportDir("target/surefire-reports");6System.out.println("Report directory: " + file.getAbsolutePath());7}8}9package com.intuit.karate;10import java.io.File;11public class 5 {12public static void main(String[] args) {13File file = Runner.reportDir("target/surefire-reports");14System.out.println("Report directory: " + file.getAbsolutePath());15}16}17package com.intuit.karate;18import java.io.File;19public class 6 {20public static void main(String[] args) {21File file = Runner.reportDir("target/surefire-reports");22System.out.println("Report directory: " + file.getAbsolutePath());23}24}25package com.intuit.karate;26import java.io.File;27public class 7 {28public static void main(String[] args) {29File file = Runner.reportDir("target/surefire-reports");30System.out.println("Report directory: " + file.getAbsolutePath());31}32}33package com.intuit.karate;34import java.io.File;35public class 8 {36public static void main(String[] args) {37File file = Runner.reportDir("target/surefire-reports");38System.out.println("Report directory: " + file.getAbsolutePath());39}40}41package com.intuit.karate;42import java.io.File;43public class 9 {44public static void main(String[] args) {45File file = Runner.reportDir("target/surefire-reports");46System.out.println("Report directory: " + file.getAbsolutePath());47}48}49package com.intuit.karate;50import java.io.File;51public class 10 {

Full Screen

Full Screen

Automation Testing Tutorials

Learn to execute automation testing from scratch with LambdaTest Learning Hub. Right from setting up the prerequisites to run your first automation test, to following best practices and diving deeper into advanced test scenarios. LambdaTest Learning Hubs compile a list of step-by-step guides to help you be proficient with different test automation frameworks i.e. Selenium, Cypress, TestNG etc.

LambdaTest Learning Hubs:

YouTube

You could also refer to video tutorials over LambdaTest YouTube channel to get step by step demonstration from industry experts.

Try LambdaTest Now !!

Get 100 minutes of automation test minutes FREE!!

Next-Gen App & Browser Testing Cloud

Was this article helpful?

Helpful

NotHelpful