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 java.io.File;
import java.time.Instant;
import java.util.ArrayList;
import java.util.Collection;
import java.util.HashMap;
import java.util.List;
import java.util.Map;
/**
*
* @author pthomas3
*/
public class ScenarioResult implements Comparable {
private final List stepResults = new ArrayList();
private final Scenario scenario;
private StepResult failedStep;
private String executorName;
private long startTime;
private long endTime;
private long durationNanos;
@Override
public int compareTo(ScenarioResult sr) {
if (sr == null) {
return 1;
}
int delta = scenario.getLine() - sr.scenario.getLine();
if (delta != 0) {
return delta;
}
return scenario.getExampleIndex() - sr.scenario.getExampleIndex();
}
public String getFailureMessageForDisplay() {
if (failedStep == null) {
return null;
}
Step step = failedStep.getStep();
String featureName = scenario.getFeature().getResource().getRelativePath();
return featureName + ":" + step.getLine() + " " + step.getText();
}
public StepResult addFakeStepResult(String message, Throwable error) {
Step step = new Step(scenario, -1);
step.setLine(scenario.getLine());
step.setPrefix("*");
step.setText(message);
Result result = error == null ? Result.passed(0) : Result.failed(0, error, step);
StepResult sr = new StepResult(step, result);
if (error != null) {
sr.setStepLog(error.getMessage());
}
addStepResult(sr);
return sr;
}
public void addStepResults(List value) {
if (value != null) {
value.forEach(this::addStepResult);
}
}
public void addStepResult(StepResult stepResult) {
stepResults.add(stepResult);
Result result = stepResult.getResult();
durationNanos += result.getDurationNanos();
if (result.isFailed()) {
failedStep = stepResult;
}
}
private static void recurse(List