use of de.dagere.peass.dependency.analysis.data.TestSet in project peass by DaGeRe.
the class ReadProperties method readChangeProperties.
public void readChangeProperties(final File changefile, final File projectFolder, final File viewFolder, final ExecutionData changedTests) throws IOException, JsonParseException, JsonMappingException, JsonGenerationException {
final File resultCSV = new File(out.getParentFile(), projectFolder.getName() + ".csv");
try (BufferedWriter csvWriter = new BufferedWriter(new FileWriter(resultCSV))) {
writeCSVHeadline(csvWriter);
final VersionChangeProperties versionProperties = new VersionChangeProperties();
final ProjectChanges changes = Constants.OBJECTMAPPER.readValue(changefile, ProjectChanges.class);
int versionCount = 0, testcaseCount = 0;
for (final Entry<String, Changes> versionChanges : changes.getVersionChanges().entrySet()) {
final String version = versionChanges.getKey();
final TestSet tests = changedTests.getVersions().get(version);
//
final String predecessor = tests != null ? tests.getPredecessor() : version + "~1";
testcaseCount += detectVersionProperty(projectFolder, viewFolder, csvWriter, versionProperties, versionChanges, predecessor, changedTests);
if (tests == null) {
LOG.error("Version not contained in runfile: " + version);
}
versionCount++;
}
// writeOnlySource(versionProperties, ProjectChanges.getOldChanges());
System.out.println("Analyzed: " + testcaseCount + " testcases in " + versionCount + " versions");
}
}
use of de.dagere.peass.dependency.analysis.data.TestSet in project peass by DaGeRe.
the class CreateOverviewStatistics method main.
public static void main(final String[] args) throws JAXBException, JsonParseException, JsonMappingException, IOException {
File dependencyFolder;
final File repos;
if (System.getenv(Constants.PEASS_REPOS) != null) {
final String repofolder = System.getenv(Constants.PEASS_REPOS);
repos = new File(repofolder);
dependencyFolder = new File(repos, "dependencies-final");
} else {
throw new RuntimeException("Please define environment variable " + Constants.PEASS_REPOS);
}
final File propertyFolder = new File(repos, "properties/properties");
final File changeFolder = new File(repos, "measurementdata/results");
final File projectsFolder = new File("../../projekte");
final DescriptiveStatistics[] stats = new DescriptiveStatistics[9];
for (int i = 0; i < 9; i++) {
stats[i] = new DescriptiveStatistics();
}
// "commons-imaging", "commons-io", "commons-numbers", "commons-pool", "commons-text", "httpcomponents-core", "k-9" }) {
for (final String project : new String[] { "commons-csv", "commons-dbcp", "commons-fileupload", "commons-jcs", "commons-imaging", "commons-io", "commons-numbers", "commons-pool", "commons-text" }) {
System.out.print(project + " & ");
final int versions = GitUtils.getVersions(new File(projectsFolder, project));
System.out.print(versions + " & ");
stats[0].addValue(versions);
final File executionFile = new File(dependencyFolder, ResultsFolders.TRACE_SELECTION_PREFIX + project + ".json");
if (executionFile.exists()) {
final ExecutionData changedTests = Constants.OBJECTMAPPER.readValue(executionFile, ExecutionData.class);
System.out.print(changedTests.getVersions().size() + " & ");
stats[1].addValue(changedTests.getVersions().size());
int tests = 0;
for (final TestSet testSet : changedTests.getVersions().values()) {
tests += testSet.getTests().size();
}
System.out.print(tests + " & ");
stats[2].addValue(tests);
int changes = 0;
int sourceChanges = 0;
int sourceTests = 0;
final File potentialChangeFolder = new File(changeFolder, project);
if (potentialChangeFolder.exists()) {
final File changefile = new File(potentialChangeFolder, project + ".json");
final ProjectChanges measuredChanges = Constants.OBJECTMAPPER.readValue(changefile, ProjectChanges.class);
changes = measuredChanges.getChangeCount();
final File changefileOnlysource = new File(propertyFolder, project + "/" + project + ".json");
if (changefileOnlysource.exists()) {
final VersionChangeProperties measuredChangesOnlysource = Constants.OBJECTMAPPER.readValue(changefileOnlysource, VersionChangeProperties.class);
for (final ChangeProperties changesAll : measuredChangesOnlysource.getVersions().values()) {
for (final List<ChangeProperty> method : changesAll.getProperties().values()) {
for (final ChangeProperty nowMetho : method) {
if (nowMetho.isAffectsSource()) {
sourceChanges++;
}
}
}
}
// sourceChanges = measuredChangesOnlysource.getChangeCount();
}
}
final File allTestProps = new File(propertyFolder, project + "/" + project + "_all.json");
if (allTestProps.exists()) {
final VersionChangeProperties properties = Constants.OBJECTMAPPER.readValue(allTestProps, VersionChangeProperties.class);
sourceTests = properties.getSourceChanges();
}
// System.out.print(sourceTests + " & ");
// stats[3].addValue(sourceTests);
System.out.print(changes + " & ");
stats[4].addValue(changes);
System.out.print(sourceChanges + " & ");
stats[5].addValue(sourceChanges);
final File changeTestProperties = new File(propertyFolder, project + File.separator + project + ".json");
if (changeTestProperties.exists()) {
final VersionChangeProperties versionProperties = Constants.OBJECTMAPPER.readValue(changeTestProperties, VersionChangeProperties.class);
final ProjectStatistics projectStatistics = new ProjectStatistics();
versionProperties.executeProcessor(projectStatistics);
System.out.print(new DecimalFormat("##.##").format(projectStatistics.affectedLines.getMean()) + " & ");
stats[6].addValue(projectStatistics.affectedLines.getMean());
System.out.print(new DecimalFormat("##.##").format(projectStatistics.calls.getMean()) + " & ");
stats[7].addValue(projectStatistics.calls.getMean());
final double durationMeanChange = projectStatistics.changes.getMean();
System.out.print(new DecimalFormat("##.##").format(durationMeanChange) + " \\% ");
stats[8].addValue(durationMeanChange);
}
}
System.out.print(" \\\\");
System.out.println();
}
System.out.println("\\hline");
System.out.print(" & ");
for (int i = 0; i < 9; i++) {
System.out.print(new DecimalFormat("##.##").format(stats[i].getMean()) + " & ");
}
System.out.println();
for (int i = 0; i < 9; i++) {
System.out.print(stats[i].getSum() + " & ");
}
System.out.println();
}
use of de.dagere.peass.dependency.analysis.data.TestSet in project peass by DaGeRe.
the class MissingExecutionFinder method removeXMLExecutions.
private void removeXMLExecutions(final File folder) throws JAXBException {
for (final File measurementFile : folder.listFiles()) {
if (measurementFile.getName().endsWith(".xml")) {
LOG.info("File:" + measurementFile);
final Kopemedata data = new XMLDataLoader(measurementFile).getFullData();
for (final TestcaseType testcase : data.getTestcases().getTestcase()) {
final String testmethod = testcase.getName();
for (final Chunk c : testcase.getDatacollector().get(0).getChunk()) {
final String version = findVersion(c);
LOG.debug("Removing {}", version);
final TestSet versionsTests = tests.getVersions().get(version);
if (versionsTests != null) {
removeTestFromTestSet(data.getTestcases().getClazz(), testmethod, versionsTests);
}
}
}
}
}
}
use of de.dagere.peass.dependency.analysis.data.TestSet in project peass by DaGeRe.
the class TestExecutionMerging method createExecutionData.
private ExecutionData createExecutionData(final int index) {
switch(index) {
case 0:
ExecutionData ex1 = new ExecutionData();
ex1.addCall("v01", new TestSet("TestA"));
ex1.addCall("v02", new TestSet("TestB"));
ex1.addCall("v03", new TestSet("TestC"));
return ex1;
case 1:
ExecutionData ex2 = new ExecutionData();
ex2.addCall("asd12", new TestSet("TestA"));
ex2.addCall("asd13", new TestSet("TestB"));
ex2.addCall("asd14", new TestSet("TestC"));
return ex2;
case 2:
ExecutionData ex3 = new ExecutionData();
ex3.addCall("xyz12", new TestSet("TestA"));
ex3.addCall("xyz13", new TestSet("TestB"));
ex3.addCall("xyz14", new TestSet("TestC"));
return ex3;
}
return null;
}
use of de.dagere.peass.dependency.analysis.data.TestSet in project peass by DaGeRe.
the class TestChangedTraceTestSerialisation method testModule.
@Test
public void testModule() throws IOException {
final ExecutionData allVersionsTests = new ExecutionData();
final TestSet testSet = new TestSet();
testSet.addTest(new TestCase("MyClazz", "myMethod", "module-3-bla"));
allVersionsTests.addCall("v1", testSet);
final String serialized = Constants.OBJECTMAPPER.writeValueAsString(allVersionsTests);
System.out.println(serialized);
final ExecutionData deserialized = Constants.OBJECTMAPPER.readValue(serialized, ExecutionData.class);
final TestSet testSetDeserialized = deserialized.getVersions().get("v1");
Assert.assertNotNull(testSetDeserialized);
final TestCase testcaseDeserialized = testSetDeserialized.getTests().iterator().next();
Assert.assertEquals("MyClazz", testcaseDeserialized.getClazz());
}
Aggregations