我是黄瓜新手。我正在使用Java代码/在团队城市建设中进行以下操作(即自动进行,无需人工干预)
预先感谢您的帮助
答案 0 :(得分:0)
Custom formatter below will give the lists of feature files in which all steps have passed and also lists of feature files in which any step have failed. Implement the other methods with empty methods as required. Add this to the runner in the plugins options.
public class SuccessCounter implements Reporter, Formatter {
private List<Feature> allScenarioPassedFeature;
private List<Feature> anyScenarioFailedFeature;
private boolean stepFailed;
private Feature feature;
public SuccessCounter() {
allScenarioPassedFeature = new ArrayList<Feature>();
anyScenarioFailedFeature = new ArrayList<Feature>();
}
@Override
public void result(Result arg0) {
if(stepFailed==false && arg0.getStatus() != Result.PASSED)
stepFailed = true;
}
@Override
public void close() {
System.out.println("COUNTS");
System.out.println("Passed - " + allScenarioPassedFeature.size());
System.out.println("Failed - "+anyScenarioFailedFeature.size());
}
@Override
public void eof() {
if(stepFailed)
anyScenarioFailedFeature.add(feature);
else
allScenarioPassedFeature.add(feature);
}
@Override
public void feature(Feature arg0) {
stepFailed = false;
this.feature = arg0;
}
}
Use at your own peril if u have parallel running.