Search in sources :

Example 21 with ChangedEntity

use of de.dagere.peass.dependency.analysis.data.ChangedEntity in project peass by DaGeRe.

the class DependencyDetectorNoUpdateIT method testTestChange.

@Test
public void testTestChange() throws IOException, InterruptedException, XmlPullParserException, ParseException, ViewNotFoundException {
    final File secondVersion = new File(DependencyTestConstants.VERSIONS_FOLDER, "changed_test");
    final Map<ChangedEntity, ClazzChangeData> changes = new TreeMap<>();
    DependencyDetectorTestUtil.addChange(changes, "", "defaultpackage.TestMe", "testMe");
    final ChangeManager changeManager = Mockito.mock(ChangeManager.class);
    Mockito.when(changeManager.getChanges(Mockito.any())).thenReturn(changes);
    final VersionIterator fakeIterator = new FakeFileIterator(DependencyTestConstants.CURRENT, Arrays.asList(secondVersion));
    final DependencyReader reader = DependencyDetectorTestUtil.readTwoVersions(changeManager, fakeIterator);
    System.out.println(reader.getDependencies().getVersions().get(DependencyTestConstants.VERSION_1));
    DependencyDetectorTestUtil.checkTestMeAlsoTestChange(reader, "defaultpackage.TestMe#testMe", "defaultpackage.TestMe", DependencyTestConstants.VERSION_1);
}
Also used : ChangeManager(de.dagere.peass.dependency.ChangeManager) FakeFileIterator(de.dagere.peass.dependencytests.helper.FakeFileIterator) ClazzChangeData(de.dagere.peass.dependency.changesreading.ClazzChangeData) DependencyReader(de.dagere.peass.dependency.reader.DependencyReader) VersionIterator(de.dagere.peass.vcs.VersionIterator) ChangedEntity(de.dagere.peass.dependency.analysis.data.ChangedEntity) TreeMap(java.util.TreeMap) File(java.io.File) Test(org.junit.jupiter.api.Test)

Example 22 with ChangedEntity

use of de.dagere.peass.dependency.analysis.data.ChangedEntity in project peass by DaGeRe.

the class DependencyDetectorParameterizedIT method testNormalChange.

@Test
public void testNormalChange() throws IOException, InterruptedException, XmlPullParserException, ParseException, ViewNotFoundException {
    final ChangeManager changeManager = changeManagerWithParameter();
    final VersionIterator fakeIterator = new FakeFileIterator(DependencyTestConstants.CURRENT, Arrays.asList(NORMAL_CHANGE));
    final DependencyReader reader = DependencyDetectorTestUtil.readTwoVersions(changeManager, fakeIterator);
    System.out.println(reader.getDependencies().getInitialversion().getInitialDependencies());
    VersionStaticSelection firstVersion = reader.getDependencies().getVersions().get(DependencyTestConstants.VERSION_1);
    System.out.println(firstVersion.getChangedClazzes());
    Assert.assertEquals(3, reader.getDependencies().getInitialversion().getInitialDependencies().size());
    TestSet selectedTest = firstVersion.getChangedClazzes().get(new ChangedEntity("defaultpackage.NormalDependency#onlyCalledWithOne"));
    Assert.assertEquals(new TestCase("TestMe#testMe(JUNIT_PARAMETERIZED-2)"), selectedTest.getTests().iterator().next());
}
Also used : ChangeManager(de.dagere.peass.dependency.ChangeManager) FakeFileIterator(de.dagere.peass.dependencytests.helper.FakeFileIterator) TestCase(de.dagere.peass.dependency.analysis.data.TestCase) VersionStaticSelection(de.dagere.peass.dependency.persistence.VersionStaticSelection) DependencyReader(de.dagere.peass.dependency.reader.DependencyReader) VersionIterator(de.dagere.peass.vcs.VersionIterator) ChangedEntity(de.dagere.peass.dependency.analysis.data.ChangedEntity) TestSet(de.dagere.peass.dependency.analysis.data.TestSet) Test(org.junit.jupiter.api.Test)

Example 23 with ChangedEntity

use of de.dagere.peass.dependency.analysis.data.ChangedEntity in project peass by DaGeRe.

the class DependencyDetectorParametersIT method changeManagerWithParameter.

public static ChangeManager changeManagerWithParameter() {
    final Map<ChangedEntity, ClazzChangeData> changes = DependencyDetectorTestUtil.buildChanges("", "defaultpackage.NormalDependency", "innerMethod(java.lang.Integer)");
    final ChangeManager changeManager = Mockito.mock(ChangeManager.class);
    Mockito.when(changeManager.getChanges(Mockito.any())).thenReturn(changes);
    return changeManager;
}
Also used : ChangeManager(de.dagere.peass.dependency.ChangeManager) ClazzChangeData(de.dagere.peass.dependency.changesreading.ClazzChangeData) ChangedEntity(de.dagere.peass.dependency.analysis.data.ChangedEntity)

Example 24 with ChangedEntity

use of de.dagere.peass.dependency.analysis.data.ChangedEntity in project peass by DaGeRe.

the class TestCoverageBasedSelection method testTwoTestsSelection.

@Test
public void testTwoTestsSelection() {
    List<TraceCallSummary> traces = getTraceSummaryList();
    Set<ChangedEntity> changes = new HashSet<>();
    changes.add(new ChangedEntity("de.dagere.peass.ExampleClazz", "", "method1"));
    changes.add(new ChangedEntity("de.dagere.peass.ExampleClazzB", "", "method0"));
    CoverageSelectionVersion selection = CoverageBasedSelector.selectBasedOnCoverage(traces, changes);
    Set<TestCase> selected = selection.getTestcases().keySet();
    MatcherAssert.assertThat(selected, IsIterableContaining.hasItem(new TestCase("ClazzA#testA")));
    MatcherAssert.assertThat(selected, IsIterableContaining.hasItem(new TestCase("ClazzC#testC")));
    TraceCallSummary summaryA = selection.getTestcases().get(new TestCase("ClazzA#testA"));
    TraceCallSummary summaryB = selection.getTestcases().get(new TestCase("ClazzB#testB"));
    TraceCallSummary summaryC = selection.getTestcases().get(new TestCase("ClazzC#testC"));
    Assert.assertEquals(summaryA.getOverallScore(), 3);
    Assert.assertEquals(summaryB.getOverallScore(), 0);
    Assert.assertEquals(summaryC.getOverallScore(), 10);
    Assert.assertEquals(summaryA.isSelected(), true);
    Assert.assertEquals(summaryB.isSelected(), false);
    Assert.assertEquals(summaryC.isSelected(), true);
    MatcherAssert.assertThat(summaryA.getSelectedChanges(), IsIterableContaining.hasItem("de.dagere.peass.ExampleClazz#method1"));
    MatcherAssert.assertThat(summaryB.getSelectedChanges(), IsEmptyCollection.empty());
    MatcherAssert.assertThat(summaryC.getSelectedChanges(), IsIterableContaining.hasItem("de.dagere.peass.ExampleClazzB#method0"));
}
Also used : TestCase(de.dagere.peass.dependency.analysis.data.TestCase) ChangedEntity(de.dagere.peass.dependency.analysis.data.ChangedEntity) HashSet(java.util.HashSet) Test(org.junit.jupiter.api.Test)

Example 25 with ChangedEntity

use of de.dagere.peass.dependency.analysis.data.ChangedEntity in project peass by DaGeRe.

the class TestCoverageBasedSelection method testSelectionBasedOnParameterizedChange.

@Test
public void testSelectionBasedOnParameterizedChange() {
    List<TraceCallSummary> traces = getTraceSummaryList();
    Set<ChangedEntity> changes = new HashSet<>();
    ChangedEntity entityWithIntParameter = new ChangedEntity("de.dagere.peass.ExampleClazz", "", "method2");
    entityWithIntParameter.getParameters().add("int");
    changes.add(entityWithIntParameter);
    Set<TestCase> selected = CoverageBasedSelector.selectBasedOnCoverage(traces, changes).getTestcases().keySet();
    MatcherAssert.assertThat(selected, IsIterableContaining.hasItem(new TestCase("ClazzA#testA")));
}
Also used : TestCase(de.dagere.peass.dependency.analysis.data.TestCase) ChangedEntity(de.dagere.peass.dependency.analysis.data.ChangedEntity) HashSet(java.util.HashSet) Test(org.junit.jupiter.api.Test)

Aggregations

ChangedEntity (de.dagere.peass.dependency.analysis.data.ChangedEntity)138 Test (org.junit.jupiter.api.Test)58 File (java.io.File)57 ClazzChangeData (de.dagere.peass.dependency.changesreading.ClazzChangeData)41 TestCase (de.dagere.peass.dependency.analysis.data.TestCase)25 TestSet (de.dagere.peass.dependency.analysis.data.TestSet)21 ChangeManager (de.dagere.peass.dependency.ChangeManager)18 Set (java.util.Set)17 HashSet (java.util.HashSet)16 ExecutionConfig (de.dagere.peass.config.ExecutionConfig)14 HashMap (java.util.HashMap)14 Map (java.util.Map)13 DependencyReader (de.dagere.peass.dependency.reader.DependencyReader)11 FakeFileIterator (de.dagere.peass.dependencytests.helper.FakeFileIterator)11 VersionIterator (de.dagere.peass.vcs.VersionIterator)10 TreeMap (java.util.TreeMap)9 VersionStaticSelection (de.dagere.peass.dependency.persistence.VersionStaticSelection)8 StaticTestSelection (de.dagere.peass.dependency.persistence.StaticTestSelection)6 EnvironmentVariables (de.dagere.peass.execution.utils.EnvironmentVariables)6 LinkedList (java.util.LinkedList)6