Search in sources :

Example 16 with StaticTestSelection

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);
}
Also used : ChangeManager(de.dagere.peass.dependency.ChangeManager) FakeFileIterator(de.dagere.peass.dependencytests.helper.FakeFileIterator) EnvironmentVariables(de.dagere.peass.execution.utils.EnvironmentVariables) DependencyReader(de.dagere.peass.dependency.reader.DependencyReader) VersionIterator(de.dagere.peass.vcs.VersionIterator) ExecutionConfig(de.dagere.peass.config.ExecutionConfig) File(java.io.File) KiekerConfig(de.dagere.peass.config.KiekerConfig) PeassFolders(de.dagere.peass.folders.PeassFolders) StaticTestSelection(de.dagere.peass.dependency.persistence.StaticTestSelection) Test(org.junit.jupiter.api.Test)

Example 17 with StaticTestSelection

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());
}
Also used : InitialVersion(de.dagere.peass.dependency.persistence.InitialVersion) VersionStaticSelection(de.dagere.peass.dependency.persistence.VersionStaticSelection) StaticTestSelection(de.dagere.peass.dependency.persistence.StaticTestSelection) Test(org.junit.jupiter.api.Test)

Example 18 with StaticTestSelection

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;
}
Also used : Set(java.util.Set) HashSet(java.util.HashSet) TestSet(de.dagere.peass.dependency.analysis.data.TestSet) ChangedEntity(de.dagere.peass.dependency.analysis.data.ChangedEntity) LinkedList(java.util.LinkedList) TestCase(de.dagere.peass.dependency.analysis.data.TestCase) VersionStaticSelection(de.dagere.peass.dependency.persistence.VersionStaticSelection) Map(java.util.Map) StaticTestSelection(de.dagere.peass.dependency.persistence.StaticTestSelection) HashSet(java.util.HashSet) TestSet(de.dagere.peass.dependency.analysis.data.TestSet)

Example 19 with StaticTestSelection

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;
}
Also used : IOException(java.io.IOException) LinkedList(java.util.LinkedList) StaticTestSelection(de.dagere.peass.dependency.persistence.StaticTestSelection)

Example 20 with StaticTestSelection

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;
}
Also used : StaticTestSelection(de.dagere.peass.dependency.persistence.StaticTestSelection)

Aggregations

StaticTestSelection (de.dagere.peass.dependency.persistence.StaticTestSelection)56 File (java.io.File)24 Test (org.junit.jupiter.api.Test)22 ExecutionConfig (de.dagere.peass.config.ExecutionConfig)14 PeassFolders (de.dagere.peass.folders.PeassFolders)14 ExecutionData (de.dagere.peass.dependency.persistence.ExecutionData)12 VersionStaticSelection (de.dagere.peass.dependency.persistence.VersionStaticSelection)12 LinkedList (java.util.LinkedList)9 TestCase (de.dagere.peass.dependency.analysis.data.TestCase)8 KiekerConfig (de.dagere.peass.config.KiekerConfig)7 InitialVersion (de.dagere.peass.dependency.persistence.InitialVersion)7 EnvironmentVariables (de.dagere.peass.execution.utils.EnvironmentVariables)7 VersionIteratorGit (de.dagere.peass.vcs.VersionIteratorGit)7 ChangedEntity (de.dagere.peass.dependency.analysis.data.ChangedEntity)6 DependencyReader (de.dagere.peass.dependency.reader.DependencyReader)6 GitCommit (de.dagere.peass.vcs.GitCommit)6 TestSet (de.dagere.peass.dependency.analysis.data.TestSet)5 ResultsFolders (de.dagere.peass.folders.ResultsFolders)5 GitUtils (de.dagere.peass.vcs.GitUtils)5 ChangeManager (de.dagere.peass.dependency.ChangeManager)4