use of de.dagere.peass.dependency.persistence.StaticTestSelection in project peass by DaGeRe.
the class DependencyDetectorMultimoduleIT method testTwoChanges.
@Test
public void testTwoChanges() throws IOException, XmlPullParserException, InterruptedException, ParseException, ViewNotFoundException {
final File thirdVersion = new File(VERSIONS_FOLDER, "another_change");
final VersionIterator fakeIterator = new FakeFileIterator(DependencyTestConstants.CURRENT, Arrays.asList(thirdVersion));
ChangeManager changeManager = mockChangeManager();
final DependencyReader reader = new DependencyReader(DependencyTestConstants.DEFAULT_CONFIG_NO_VIEWS, new PeassFolders(DependencyTestConstants.CURRENT), DependencyTestConstants.NULL_RESULTS_FOLDERS, null, fakeIterator, changeManager, new ExecutionConfig(5), new KiekerConfig(true), new EnvironmentVariables());
final boolean success = reader.readInitialVersion();
Assert.assertTrue(success);
StaticTestSelection dependencies = reader.getDependencies();
checkInitialVersion(dependencies);
fakeIterator.goToNextCommit();
reader.analyseVersion(changeManager);
testFirstChange(dependencies);
testSecondChange(dependencies);
}
use of de.dagere.peass.dependency.persistence.StaticTestSelection in project peass by DaGeRe.
the class TestDependencies method testRunningersions.
@Test
public void testRunningersions() {
StaticTestSelection dependencies = new StaticTestSelection();
dependencies.setInitialversion(new InitialVersion());
dependencies.getInitialversion().setVersion("0");
VersionStaticSelection running1 = new VersionStaticSelection();
running1.setRunning(true);
dependencies.getVersions().put("1", running1);
VersionStaticSelection nonRunning2 = new VersionStaticSelection();
nonRunning2.setRunning(false);
dependencies.getVersions().put("2", nonRunning2);
VersionStaticSelection running3 = new VersionStaticSelection();
running3.setRunning(true);
dependencies.getVersions().put("3", running3);
String[] versionNames = dependencies.getRunningVersionNames();
Assert.assertEquals("0", versionNames[0]);
Assert.assertEquals("1", versionNames[1]);
Assert.assertEquals("3", versionNames[2]);
Assert.assertEquals("3", dependencies.getNewestVersion());
}
use of de.dagere.peass.dependency.persistence.StaticTestSelection in project peass by DaGeRe.
the class DependencyStatisticAnalyzer method getChangeStatistics.
public static DependencyStatistics getChangeStatistics(final File dependenciesFile, final ExecutionData changedTests) throws JAXBException, JsonParseException, JsonMappingException, IOException {
final StaticTestSelection dependencies = Constants.OBJECTMAPPER.readValue(dependenciesFile, StaticTestSelection.class);
final Map<String, VersionStaticSelection> versions = dependencies.getVersions();
final int startTestCound = dependencies.getInitialversion().getInitialDependencies().size();
final List<TestCase> currentContainedTests = new LinkedList<>();
for (final TestCase dependency : dependencies.getInitialversion().getInitialDependencies().keySet()) {
currentContainedTests.add(dependency);
}
LOG.trace("StartTest: {}", startTestCound);
// final List<TestCase> sometimesChangedTest = new LinkedList<>(); // Nicht nur Vorkommen, auch Anzahl relevant
final DependencyStatistics statistics = new DependencyStatistics();
// final List<TestCase> onlyOnceChangedTests = new LinkedList<>();
statistics.onceChangedTests.addAll(currentContainedTests);
statistics.size = versions.size();
// final int pruningRunTests = 0;
for (final Entry<String, VersionStaticSelection> version : versions.entrySet()) {
final Set<TestCase> currentIterationTests = new HashSet<>();
for (final Map.Entry<ChangedEntity, TestSet> dependency : version.getValue().getChangedClazzes().entrySet()) {
for (final Entry<TestCase, Set<String>> testcase : dependency.getValue().getTestcases().entrySet()) {
final String testclass = testcase.getKey().getClazz();
for (final String method : testcase.getValue()) {
final TestCase testcase2 = new TestCase(testclass, method);
// final String testname = testclass + "." + method;
if (currentContainedTests.contains(testcase2)) {
currentIterationTests.add(testcase2);
} else {
currentContainedTests.add(testcase2);
statistics.onceChangedTests.add(testcase2);
// LOG.info("Neuer Test: " + testname);
}
}
}
}
int currentTraceChangedTests = 0;
if (changedTests != null) {
for (final TestCase currentIterationTest : currentContainedTests) {
if (changedTests.versionContainsTest(version.getKey(), currentIterationTest)) {
currentTraceChangedTests++;
}
}
}
LOG.trace("Version: {} Tests: {} Trace-Changed: {}", version.getKey(), currentIterationTests.size(), currentTraceChangedTests);
statistics.multipleChangedTest.addAll(currentIterationTests);
statistics.onceChangedTests.removeAll(currentIterationTests);
statistics.changedTraceTests += currentTraceChangedTests;
statistics.pruningRunTests += currentIterationTests.size();
statistics.overallRunTests += currentContainedTests.size();
}
return statistics;
}
use of de.dagere.peass.dependency.persistence.StaticTestSelection in project peass by DaGeRe.
the class PartialDependenciesMerger method readDependencies.
static List<StaticTestSelection> readDependencies(final File[] partFiles) {
final List<StaticTestSelection> deps = new LinkedList<>();
for (int i = 0; i < partFiles.length; i++) {
try {
LOG.debug("Reading: {}", partFiles[i]);
final StaticTestSelection currentDependencies = Constants.OBJECTMAPPER.readValue(partFiles[i], StaticTestSelection.class);
deps.add(currentDependencies);
LOG.debug("Size: {}", deps.get(deps.size() - 1).getVersions().size());
} catch (final IOException e) {
e.printStackTrace();
}
}
return deps;
}
use of de.dagere.peass.dependency.persistence.StaticTestSelection in project peass by DaGeRe.
the class PartialDependenciesMerger method mergeVersions.
public static StaticTestSelection mergeVersions(final File out, final File[] partFiles) throws IOException, JsonGenerationException, JsonMappingException {
final List<StaticTestSelection> deps = readDependencies(partFiles);
StaticTestSelection merged = mergeDependencies(deps);
Constants.OBJECTMAPPER.writeValue(out, merged);
return merged;
}
Aggregations