Search in sources :

Example 26 with DependencyReader

use of de.dagere.peass.dependency.reader.DependencyReader 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");
}
Also used : ChangeManager(de.dagere.peass.dependency.ChangeManager) FakeFileIterator(de.dagere.peass.dependencytests.helper.FakeFileIterator) DependencyReader(de.dagere.peass.dependency.reader.DependencyReader) VersionIterator(de.dagere.peass.vcs.VersionIterator) File(java.io.File) Test(org.junit.jupiter.api.Test)

Example 27 with DependencyReader

use of de.dagere.peass.dependency.reader.DependencyReader 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());
}
Also used : ChangeManager(de.dagere.peass.dependency.ChangeManager) FakeFileIterator(de.dagere.peass.dependencytests.helper.FakeFileIterator) ClazzChangeData(de.dagere.peass.dependency.changesreading.ClazzChangeData) TestCase(de.dagere.peass.dependency.analysis.data.TestCase) 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) TestSet(de.dagere.peass.dependency.analysis.data.TestSet) Test(org.junit.jupiter.api.Test)

Example 28 with DependencyReader

use of de.dagere.peass.dependency.reader.DependencyReader in project peass by DaGeRe.

the class DependencyDetectorIncludesTest method testNormalChangeNotIncluded.

@Test
public void testNormalChangeNotIncluded() throws IOException, InterruptedException, XmlPullParserException, ParseException, ViewNotFoundException {
    final File secondVersion = new File(DependencyTestConstants.VERSIONS_FOLDER, "normal_change");
    final ChangeManager changeManager = DependencyDetectorTestUtil.defaultChangeManager();
    final DependencyReader reader = executeWithInclude("defaultpackage.TestMe#removeMe", secondVersion, changeManager);
    checkContainsOnlyRemoveMe(reader);
}
Also used : ChangeManager(de.dagere.peass.dependency.ChangeManager) DependencyReader(de.dagere.peass.dependency.reader.DependencyReader) File(java.io.File) Test(org.junit.jupiter.api.Test)

Example 29 with DependencyReader

use of de.dagere.peass.dependency.reader.DependencyReader in project peass by DaGeRe.

the class DependencyDetectorIncludesTest method testNormalChangeAddedClass.

@Test
public void testNormalChangeAddedClass() throws IOException, InterruptedException, XmlPullParserException, ParseException, ViewNotFoundException {
    final File secondVersion = new File(DependencyTestConstants.VERSIONS_FOLDER, "added_class");
    final ChangeManager changeManager = DependencyDetectorTestUtil.mockAddedChangeManager();
    final DependencyReader reader = executeWithInclude("defaultpackage.TestMe#testMe", secondVersion, changeManager);
    checkContainsOnlyTestMeNoAddition(reader);
}
Also used : ChangeManager(de.dagere.peass.dependency.ChangeManager) DependencyReader(de.dagere.peass.dependency.reader.DependencyReader) File(java.io.File) Test(org.junit.jupiter.api.Test)

Example 30 with DependencyReader

use of de.dagere.peass.dependency.reader.DependencyReader 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());
}
Also used : ChangeManager(de.dagere.peass.dependency.ChangeManager) FakeFileIterator(de.dagere.peass.dependencytests.helper.FakeFileIterator) TestCase(de.dagere.peass.dependency.analysis.data.TestCase) DependencyReader(de.dagere.peass.dependency.reader.DependencyReader) VersionIterator(de.dagere.peass.vcs.VersionIterator) File(java.io.File) TestSet(de.dagere.peass.dependency.analysis.data.TestSet) EnabledForJreRange(org.junit.jupiter.api.condition.EnabledForJreRange) Test(org.junit.jupiter.api.Test)

Aggregations

DependencyReader (de.dagere.peass.dependency.reader.DependencyReader)36 Test (org.junit.jupiter.api.Test)28 FakeFileIterator (de.dagere.peass.dependencytests.helper.FakeFileIterator)27 ChangeManager (de.dagere.peass.dependency.ChangeManager)26 VersionIterator (de.dagere.peass.vcs.VersionIterator)24 File (java.io.File)21 ExecutionConfig (de.dagere.peass.config.ExecutionConfig)11 ChangedEntity (de.dagere.peass.dependency.analysis.data.ChangedEntity)11 EnvironmentVariables (de.dagere.peass.execution.utils.EnvironmentVariables)11 PeassFolders (de.dagere.peass.folders.PeassFolders)11 ClazzChangeData (de.dagere.peass.dependency.changesreading.ClazzChangeData)10 KiekerConfig (de.dagere.peass.config.KiekerConfig)9 TreeMap (java.util.TreeMap)7 StaticTestSelection (de.dagere.peass.dependency.persistence.StaticTestSelection)6 TestSet (de.dagere.peass.dependency.analysis.data.TestSet)5 VersionKeeper (de.dagere.peass.dependency.reader.VersionKeeper)5 ResultsFolders (de.dagere.peass.folders.ResultsFolders)5 TestCase (de.dagere.peass.dependency.analysis.data.TestCase)4 GitUtils (de.dagere.peass.vcs.GitUtils)4 TestSelectionConfig (de.dagere.peass.config.TestSelectionConfig)3