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);
}
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());
}
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;
}
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"));
}
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")));
}
Aggregations