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

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

Source:Runner.java Github

copy

Full Screen

...150 ClassLoader classLoader;151 Class optionsClass;152 String env;153 File workingDir;154 String buildDir;155 String configDir;156 int threadCount;157 int timeoutMinutes;158 String reportDir;159 String scenarioName;160 List<String> tags;161 List<String> paths;162 List<Feature> features;163 String relativeTo;164 final Collection<RuntimeHook> hooks = new ArrayList();165 RuntimeHookFactory hookFactory;166 HttpClientFactory clientFactory;167 boolean forTempUse;168 boolean backupReportDir = true;169 boolean outputHtmlReport = true;170 boolean outputJunitXml;171 boolean outputCucumberJson;172 boolean dryRun;173 boolean debugMode;174 Map<String, String> systemProperties;175 Map<String, Object> callSingleCache;176 Map<String, ScenarioCall.Result> callOnceCache;177 SuiteReports suiteReports;178 JobConfig jobConfig;179 Map<String, DriverRunner> drivers;180 // synchronize because the main user is karate-gatling181 public synchronized Builder copy() {182 Builder b = new Builder();183 b.classLoader = classLoader;184 b.optionsClass = optionsClass;185 b.env = env;186 b.workingDir = workingDir;187 b.buildDir = buildDir;188 b.configDir = configDir;189 b.threadCount = threadCount;190 b.timeoutMinutes = timeoutMinutes;191 b.reportDir = reportDir;192 b.scenarioName = scenarioName;193 b.tags = tags;194 b.paths = paths;195 b.features = features;196 b.relativeTo = relativeTo;197 b.hooks.addAll(hooks); // final198 b.hookFactory = hookFactory;199 b.clientFactory = clientFactory;200 b.forTempUse = forTempUse;201 b.backupReportDir = backupReportDir;202 b.outputHtmlReport = outputHtmlReport;203 b.outputJunitXml = outputJunitXml;204 b.outputCucumberJson = outputCucumberJson;205 b.dryRun = dryRun;206 b.debugMode = debugMode;207 b.systemProperties = systemProperties;208 b.callSingleCache = callSingleCache;209 b.callOnceCache = callOnceCache;210 b.suiteReports = suiteReports;211 b.jobConfig = jobConfig;212 b.drivers = drivers;213 return b;214 }215 public List<Feature> resolveAll() {216 if (classLoader == null) {217 classLoader = Thread.currentThread().getContextClassLoader();218 }219 if (clientFactory == null) {220 clientFactory = HttpClientFactory.DEFAULT;221 }222 if (systemProperties == null) {223 systemProperties = new HashMap(System.getProperties());224 } else {225 systemProperties.putAll(new HashMap(System.getProperties()));226 }227 // env228 String tempOptions = StringUtils.trimToNull(systemProperties.get(Constants.KARATE_OPTIONS));229 if (tempOptions != null) {230 LOGGER.info("using system property '{}': {}", Constants.KARATE_OPTIONS, tempOptions);231 Main ko = Main.parseKarateOptions(tempOptions);232 if (ko.tags != null) {233 tags = ko.tags;234 }235 if (ko.paths != null) {236 paths = ko.paths;237 }238 dryRun = ko.dryRun || dryRun;239 }240 String tempEnv = StringUtils.trimToNull(systemProperties.get(Constants.KARATE_ENV));241 if (tempEnv != null) {242 LOGGER.info("using system property '{}': {}", Constants.KARATE_ENV, tempEnv);243 env = tempEnv;244 } else if (env != null) {245 LOGGER.info("karate.env is: '{}'", env);246 }247 // config dir248 String tempConfig = StringUtils.trimToNull(systemProperties.get(Constants.KARATE_CONFIG_DIR));249 if (tempConfig != null) {250 LOGGER.info("using system property '{}': {}", Constants.KARATE_CONFIG_DIR, tempConfig);251 configDir = tempConfig;252 }253 if (workingDir == null) {254 workingDir = FileUtils.WORKING_DIR;255 }256 if (configDir == null) {257 try {258 ResourceUtils.getResource(workingDir, "classpath:karate-config.js");259 configDir = "classpath:"; // default mode260 } catch (Exception e) {261 configDir = workingDir.getPath();262 }263 }264 if (configDir.startsWith("file:") || configDir.startsWith("classpath:")) {265 // all good266 } else {267 configDir = "file:" + configDir;268 }269 if (configDir.endsWith(":") || configDir.endsWith("/") || configDir.endsWith("\\")) {270 // all good271 } else {272 configDir = configDir + File.separator;273 }274 if (buildDir == null) {275 buildDir = FileUtils.getBuildDir();276 }277 if (reportDir == null) {278 reportDir = buildDir + File.separator + Constants.KARATE_REPORTS;279 }280 // hooks281 if (hookFactory != null) {282 hook(hookFactory.create());283 }284 // features285 if (features == null) {286 if (paths != null && !paths.isEmpty()) {287 if (relativeTo != null) {288 paths = paths.stream().map(p -> {289 if (p.startsWith("classpath:")) {290 return p;291 }292 if (!p.endsWith(".feature")) {293 p = p + ".feature";294 }295 return relativeTo + "/" + p;296 }).collect(Collectors.toList());297 }298 } else if (relativeTo != null) {299 paths = new ArrayList();300 paths.add(relativeTo);301 }302 features = ResourceUtils.findFeatureFiles(workingDir, paths);303 }304 if (scenarioName != null) {305 for (Feature feature : features) {306 feature.setCallName(scenarioName);307 }308 }309 if (callSingleCache == null) {310 callSingleCache = new HashMap();311 }312 if (callOnceCache == null) {313 callOnceCache = new HashMap();314 }315 if (suiteReports == null) {316 suiteReports = SuiteReports.DEFAULT;317 }318 if (drivers != null) {319 Map<String, DriverRunner> customDrivers = drivers;320 drivers = DriverOptions.driverRunners();321 drivers.putAll(customDrivers); // allows override of Karate drivers (e.g. custom 'chrome')322 } else {323 drivers = DriverOptions.driverRunners();324 }325 if (jobConfig != null) {326 reportDir = jobConfig.getExecutorDir();327 if (threadCount < 1) {328 threadCount = jobConfig.getExecutorCount();329 }330 timeoutMinutes = jobConfig.getTimeoutMinutes();331 }332 if (threadCount < 1) {333 threadCount = 1;334 }335 return features;336 }337 protected T forTempUse() {338 forTempUse = true;339 return (T) this;340 }341 //======================================================================342 //343 public T configDir(String dir) {344 this.configDir = dir;345 return (T) this;346 }347 public T karateEnv(String env) {348 this.env = env;349 return (T) this;350 }351 public T systemProperty(String key, String value) {352 if (systemProperties == null) {353 systemProperties = new HashMap();354 }355 systemProperties.put(key, value);356 return (T) this;357 }358 public T workingDir(File value) {359 if (value != null) {360 this.workingDir = value;361 }362 return (T) this;363 }364 public T buildDir(String value) {365 if (value != null) {366 this.buildDir = value;367 }368 return (T) this;369 }370 public T classLoader(ClassLoader value) {371 classLoader = value;372 return (T) this;373 }374 public T relativeTo(Class clazz) {375 relativeTo = "classpath:" + ResourceUtils.toPathFromClassPathRoot(clazz);376 return (T) this;377 }378 /**379 * @see com.intuit.karate.Runner#builder()380 * @deprecated...

Full Screen

Full Screen

buildDir

Using AI Code Generation

copy

Full Screen

1import com.intuit.karate.Runner;2import com.intuit.karate.Results;3import com.intuit.karate.Runner.Builder;4import java.io.File;5public class KarateRunner {6 public static void main(String[] args) {7 String karateOutputPath = "target/surefire-reports";8 Builder builder = Runner.path("classpath:com/karate/demos/demo1").outputCucumberJson(true).outputHtmlReport(true).outputJunitXml(true);9 builder.buildDir(karateOutputPath);10 Results results = builder.parallel(5);11 if (results.getFailCount() > 0) {12 System.exit(1);13 }14 }15}

Full Screen

Full Screen

buildDir

Using AI Code Generation

copy

Full Screen

1File file = new File(buildDir, karateOutputPath)2file.mkdirs()3def buildDir = System.getProperty('project.build.directory')4File file = new File(buildDir, karateOutputPath)5file.mkdirs()6def buildDir = System.getProperty('buildDir')7File file = new File(buildDir, karateOutputPath)8file.mkdirs()9def buildDir = System.getProperty('buildDir')10File file = new File(buildDir, karateOutputPath)11file.mkdirs()12def jsonReportPath = "${karateOutputPath}/cucumber.json"13def htmlReportPath = "${karateOutputPath}/cucumber-report.html"14def jsonReport = new File(jsonReportPath)15def htmlReport = new File(htmlReportPath)16if (jsonReport.exists()) {17 com.intuit.karate.Results results = com.intuit.karate.Results.parseJson(jsonReport.text)18 results.writeHtmlReport(htmlReport)19 results.writeJunitXmlReport(htmlReport.parentFile)20}

Full Screen

Full Screen

buildDir

Using AI Code Generation

copy

Full Screen

1def buildDir = com.intuit.karate.Runner.buildDir('src/test/java/com/intuit/karate/demo')2def result = com.intuit.karate.Runner.parallel(buildDir, 5)3assert result.getFailCount() == 04def result = com.intuit.karate.Runner.parallel('src/test/java/com/intuit/karate/demo/demo.feature', 5)5assert result.getFailCount() == 06def result = com.intuit.karate.Runner.parallel('src/test/java/com/intuit/karate/demo/demo.feature', 5, config)7assert result.getFailCount() == 08def result = com.intuit.karate.Runner.parallel('src/test/java/com/intuit/karate/demo/demo.feature', 5, config, env)9assert result.getFailCount() == 010def result = com.intuit.karate.Runner.parallel('src/test/java/com/intuit/karate/demo/demo.feature', 5, config, env, tags)11assert result.getFailCount() == 012def result = com.intuit.karate.Runner.parallel('src/test/java/com/intuit/karate/demo/demo.feature', 5, config, env, tags, karateConfig)13assert result.getFailCount() == 0

Full Screen

Full Screen

buildDir

Using AI Code Generation

copy

Full Screen

1import com.intuit.karate.Runner2import static com.intuit.karate.FileUtils.buildDir3import static com.intuit.karate.FileUtils.buildFile4def outputDir = buildDir('target/surefire-reports')5def parallel = System.getProperty('karate.parallel') != null6def result = Runner.path('classpath:com/intuit/karate/demo').tags('~@ignore').parallel(parallel)7def htmlReport = new File(outputDir, 'karate.html')8def jsonReport = new File(outputDir, 'karate.json')9result.writePrettyHtmlReport(htmlReport)10result.writeJsonReport(jsonReport)11def json = new File(outputDir, 'karate.json').text12def summary = new File(outputDir, 'karate-summary.txt')13summary.write("14Karate version: ${com.intuit.karate.Constants.KARATE_VERSION}")15summary.append("16Karate results: ${json}")17summary.append("18summary.append("19summary.append("20if (result.getFailCount() > 0) {21 throw new RuntimeException('there were scenario failures')22}

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