use of de.dagere.peass.dependencytests.helper.FakeFileIterator in project peass by DaGeRe.
the class DependencyDetectorIT method testNoChange.
@Test
public void testNoChange() throws Exception {
final Map<ChangedEntity, ClazzChangeData> changes = new HashMap<>();
final ChangeManager changeManager = Mockito.mock(ChangeManager.class);
Mockito.when(changeManager.getChanges(Mockito.any())).thenReturn(changes);
final VersionIterator fakeIterator = new FakeFileIterator(DependencyTestConstants.CURRENT, Arrays.asList(DependencyTestConstants.BASIC_STATE));
final DependencyReader reader = DependencyDetectorTestUtil.readTwoVersions(changeManager, fakeIterator);
StaticTestSelection dependencies = reader.getDependencies();
System.out.println(dependencies.getVersions());
Assert.assertTrue(dependencies.getVersions().get(dependencies.getNewestVersion()).isRunning());
// DependencyDetectorTestUtil.checkTestMeAlsoTestChange(reader, "defaultpackage.NormalDependency#executeThing", "defaultpackage.TestMe", DependencyTestConstants.VERSION_1);
}
use of de.dagere.peass.dependencytests.helper.FakeFileIterator in project peass by DaGeRe.
the class DependencyDetectorIT method testNormalChange.
@Test
public void testNormalChange() throws Exception {
final ChangeManager changeManager = DependencyDetectorTestUtil.defaultChangeManager();
final VersionIterator fakeIterator = new FakeFileIterator(DependencyTestConstants.CURRENT, Arrays.asList(DependencyTestConstants.NORMAL_CHANGE));
final DependencyReader reader = DependencyDetectorTestUtil.readTwoVersions(changeManager, fakeIterator);
System.out.println(reader.getDependencies());
DependencyDetectorTestUtil.checkTestMeAlsoTestChange(reader, "defaultpackage.NormalDependency#executeThing", "defaultpackage.TestMe", DependencyTestConstants.VERSION_1);
}
use of de.dagere.peass.dependencytests.helper.FakeFileIterator in project peass by DaGeRe.
the class DependencyDetectorIT method testAddedTest.
@Test
public void testAddedTest() throws Exception {
final File secondVersion = new File(DependencyTestConstants.VERSIONS_FOLDER, "added_test");
final ChangeManager changeManager = DependencyDetectorTestUtil.changedTestClassChangeManager();
final VersionIterator fakeIterator = new FakeFileIterator(DependencyTestConstants.CURRENT, Arrays.asList(secondVersion));
final DependencyReader reader = DependencyDetectorTestUtil.readTwoVersions(changeManager, fakeIterator);
System.out.println(reader.getDependencies());
DependencyDetectorTestUtil.checkChange(reader, "defaultpackage.NormalDependency#executeThing", "defaultpackage.TestMe", DependencyTestConstants.VERSION_1, "addedTest");
}
use of de.dagere.peass.dependencytests.helper.FakeFileIterator in project peass by DaGeRe.
the class DependencyDetectorIT method testMethodRemoval.
/**
* Tests removal of a method. In the first version, the method should not be called (but the other method of TestMe should be called, since the class interface changed). In the
* second version, the changes should only influence TestMe.testMe, not TestMe.removeMe.
*
* @throws IOException
* @throws InterruptedException
* @throws XmlPullParserException
* @throws ViewNotFoundException
* @throws ParseException
*/
@Test
public void testMethodRemoval() throws Exception {
final File secondVersion = new File(DependencyTestConstants.VERSIONS_FOLDER, "removed_method");
final File thirdVersion = new File(DependencyTestConstants.VERSIONS_FOLDER, "removed_method_change");
final Map<ChangedEntity, ClazzChangeData> changes = new TreeMap<>();
changes.put(new ChangedEntity("defaultpackage.TestMe", ""), new ClazzChangeData("defaultpackage.TestMe", false));
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, thirdVersion));
final DependencyReader reader = DependencyDetectorTestUtil.readTwoVersions(changeManager, fakeIterator);
Assert.assertEquals(1, reader.getDependencies().getVersions().get("000001").getChangedClazzes().size());
fakeIterator.goToNextCommit();
reader.analyseVersion(changeManager);
System.out.println(reader.getDependencies());
final TestSet testMe = DependencyDetectorTestUtil.findDependency(reader.getDependencies(), "defaultpackage.TestMe", DependencyTestConstants.VERSION_2);
final TestCase test = testMe.getTests().iterator().next();
Assert.assertEquals(1, testMe.getTests().size());
Assert.assertEquals("defaultpackage.TestMe", test.getClazz());
Assert.assertEquals("testMe", test.getMethod());
}
use of de.dagere.peass.dependencytests.helper.FakeFileIterator in project peass by DaGeRe.
the class DependencyDetectorJava11IT method testNormalChange.
@Test
@EnabledForJreRange(min = JRE.JAVA_11)
public void testNormalChange() throws IOException, InterruptedException, XmlPullParserException, ParseException, ViewNotFoundException {
final File secondVersion = buildSecondVersion();
final ChangeManager changeManager = DependencyDetectorTestUtil.defaultChangeManager();
final VersionIterator fakeIterator = new FakeFileIterator(DependencyTestConstants.CURRENT, Arrays.asList(secondVersion));
final DependencyReader reader = DependencyDetectorTestUtil.readTwoVersions(changeManager, fakeIterator);
System.out.println(reader.getDependencies());
final TestSet testMe = DependencyDetectorTestUtil.findDependency(reader.getDependencies(), "defaultpackage.NormalDependency#executeThing", DependencyTestConstants.VERSION_1);
final TestCase testcase = testMe.getTests().iterator().next();
Assert.assertEquals("defaultpackage.TestMe", testcase.getClazz());
Assert.assertEquals("testMe", testcase.getMethod());
}
Aggregations