Many resources are needed to download a project. Please understand that we have to compensate our server costs. Thank you in advance. Project price only 1 $
You can buy this project and download/modify it how often you want.
/*
* The MIT License
*
* Copyright 2022 Karate Labs Inc.
*
* Permission is hereby granted, free of charge, to any person obtaining a copy
* of this software and associated documentation files (the "Software"), to deal
* in the Software without restriction, including without limitation the rights
* to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
* copies of the Software, and to permit persons to whom the Software is
* furnished to do so, subject to the following conditions:
*
* The above copyright notice and this permission notice shall be included in
* all copies or substantial portions of the Software.
*
* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
* IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
* FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
* AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
* LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
* OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
* THE SOFTWARE.
*/
package com.intuit.karate.core;
import com.intuit.karate.report.ReportUtils;
import com.intuit.karate.StringUtils;
import com.intuit.karate.JsonUtils;
import com.intuit.karate.KarateException;
import com.intuit.karate.resource.Resource;
import com.intuit.karate.resource.ResourceUtils;
import java.io.File;
import java.util.ArrayList;
import java.util.Collections;
import java.util.HashMap;
import java.util.List;
import java.util.Map;
/**
*
* @author pthomas3
*/
public class FeatureResult {
private final Feature feature;
private final List scenarioResults = new ArrayList<>();
private String resultDate;
private String displayName; // mutable for users who want to customize
private Map resultVariables;
private Map callArg;
private Config config;
private int loopIndex = -1;
private int callDepth;
public FeatureResult(Feature feature) {
this.feature = feature;
displayName = feature.getResource().getRelativePath();
}
public void printStats() {
String featureName = feature.getResource().getPrefixedPath();
StringBuilder sb = new StringBuilder();
sb.append("---------------------------------------------------------\n");
sb.append("feature: ").append(featureName).append('\n');
sb.append(String.format("scenarios: %2d | passed: %2d | failed: %2d | time: %.4f\n", getScenarioCount(), getPassedCount(), getFailedCount(), getDurationMillis() / 1000));
sb.append("---------------------------------------------------------\n");
System.out.println(sb);
}
public List getAllEmbedFiles() {
List files = new ArrayList();
for (ScenarioResult sr : scenarioResults) {
for (StepResult stepResult : sr.getStepResults()) {
if (stepResult.getEmbeds() != null) {
for (Embed embed : stepResult.getEmbeds()) {
files.add(embed.getFile());
}
}
}
}
return files;
}
public static FeatureResult fromKarateJson(File workingDir, Map map) {
String featurePath = (String) map.get("prefixedPath");
Resource resource = ResourceUtils.getResource(workingDir, featurePath);
Feature feature = Feature.read(resource);
FeatureResult fr = new FeatureResult(feature);
fr.callArg = (Map) map.get("callArg");
fr.loopIndex = (Integer) map.get("loopIndex");
fr.resultDate = (String) map.get("resultDate");
fr.callDepth = (Integer) map.get("callDepth");
List