hudson.plugins.PerfPublisher.MatrixTestReportAction Maven / Gradle / Ivy
Go to download
Show more of this group Show more artifacts with this name
Show all versions of perfpublisher Show documentation
Show all versions of perfpublisher Show documentation
The PerfPublisher plug-in scans for xml tests reports defined in the administration panel and generates trend graphs, computes stats and underline regressions and modifications. The xml files must be generated by your own testing tool.
package hudson.plugins.PerfPublisher;
import java.util.ArrayList;
import java.util.Collections;
import java.util.Comparator;
import java.util.HashMap;
import java.util.Iterator;
import java.util.List;
import java.util.Map;
import java.util.Set;
import java.util.TreeMap;
import java.util.Map.Entry;
import org.apache.commons.lang.text.StrBuilder;
import hudson.matrix.AxisList;
import hudson.matrix.MatrixBuild;
import hudson.matrix.MatrixProject;
import hudson.model.AbstractBuild;
import hudson.model.Action;
import hudson.plugins.PerfPublisher.Report.ReportContainer;
import hudson.plugins.PerfPublisher.Report.Test;
import hudson.plugins.PerfPublisher.matrixBuild.PerfPublisherMatrixBuild;
import hudson.plugins.PerfPublisher.matrixBuild.PerfPublisherMatrixSubBuild;
public class MatrixTestReportAction extends AbstractPerfPublisherAction
implements Action {
PerfPublisherMatrixBuild matrixbuild;
private int numberOfExecutedTest;
private int numberOfTest;
private int numberOfPassedTest;
private int numberOfNotExecutedTest;
private int numberOfTrueFalseTest;
private int numberOfFailedTest;
private MatrixBuild build;
private MatrixProject project;
public MatrixTestReportAction(MatrixBuild build) {
this.matrixbuild = new PerfPublisherMatrixBuild(build.getNumber());
this.build = build;
this.project = build.getProject();
}
public MatrixBuild getBuild() {
return build;
}
public MatrixProject getProject() {
return project;
}
public String getDisplayName() {
return PerfPublisherPlugin.MATRIX_BUILD_DISPLAY_NAME;
}
public String getSearchUrl() {
return PerfPublisherPlugin.URL;
}
public String getIconFileName() {
return PerfPublisherPlugin.ICON_FILE_NAME;
}
public String getUrlName() {
return PerfPublisherPlugin.URL;
}
/**
* Add a subBuild result
* @param report
* @param buildVariables
*/
public void addSubBuildResult(ReportContainer report,
Map buildVariables) {
Map buildVars = new TreeMap();
buildVars.putAll(buildVariables);
this.matrixbuild.addSubBuild(new PerfPublisherMatrixSubBuild(buildVars, report));
computeStats();
}
public PerfPublisherMatrixBuild getMatrixBuild() {
return this.matrixbuild;
}
public void computeStats() {
numberOfExecutedTest = 0;
numberOfFailedTest = 0;
numberOfTest = 0;
numberOfPassedTest = 0;
numberOfTrueFalseTest = 0;
List subBuilds = this.matrixbuild.getSubBuilds();
for (int i=0; i");
int tmp1 = this.getNumberOfFailedTest();
int tmp2 = this.getNumberOfPassedTest();
double tmp3 = this.getPercentOfFailedTest();
double tmp4 = this.getPercentOfPassedTest();
if (tmp3<15) {
strbuilder.append(""+tmp1+"");
strbuilder.append(""+tmp2+"");
} else {
strbuilder.append(""+tmp3+"% ("+tmp1+")");
strbuilder.append(""+tmp4+"% ("+tmp2+")");
}
strbuilder.append("