Search in sources :

Example 26 with TestCase

use of de.dagere.peass.dependency.analysis.data.TestCase 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)

Example 27 with TestCase

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

the class TestCoverageBasedSelection method getTraceSummaryList.

private List<TraceCallSummary> getTraceSummaryList() {
    List<Content> firstTrace = TestTraceSummaryTransformer.buildTestTrace();
    TraceCallSummary summary = TraceSummaryTransformer.transform(new TestCase("ClazzA#testA"), firstTrace);
    List<Content> secondTrace = TestTraceSummaryTransformer.buildOtherTrace();
    TraceCallSummary summary2 = TraceSummaryTransformer.transform(new TestCase("ClazzB#testB"), secondTrace);
    List<Content> betterTrace = TestTraceSummaryTransformer.buildBetterMatchingOtherTrace();
    TraceCallSummary summary3 = TraceSummaryTransformer.transform(new TestCase("ClazzC#testC"), betterTrace);
    List<TraceCallSummary> traces = Arrays.asList(summary, summary2, summary3);
    return traces;
}
Also used : TestCase(de.dagere.peass.dependency.analysis.data.TestCase) Content(de.dagere.requitur.content.Content)

Example 28 with TestCase

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

the class CoverageBasedSelectionIT method testNormalChange.

@Test
public void testNormalChange() throws IOException, InterruptedException, XmlPullParserException, ParseException, ViewNotFoundException {
    try (MockedStatic<GitUtils> staticMock = Mockito.mockStatic(GitUtils.class)) {
        final ChangeManager changeManager = DependencyDetectorTestUtil.defaultChangeManager();
        final VersionIterator fakeIterator = new FakeFileIterator(DependencyTestConstants.CURRENT, Arrays.asList(DependencyTestConstants.COVERAGE_NORMAL_CHANGE));
        final DependencyReader reader = DependencyDetectorTestUtil.readTwoVersions(changeManager, fakeIterator, new ExecutionConfig(5), DependencyTestConstants.DEFAULT_CONFIG_WITH_COVERAGE, DependencyTestConstants.TARGET_RESULTS_FOLDERS);
        System.out.println(reader.getDependencies());
        DependencyDetectorTestUtil.checkChange(reader, "defaultpackage.NormalDependency#executeThing", "defaultpackage.TestMe", DependencyTestConstants.VERSION_1, "testFirst");
        System.out.println(reader.getCoverageBasedSelection());
        TestSet tests = reader.getCoverageBasedSelection().getVersions().get(DependencyTestConstants.VERSION_1);
        MatcherAssert.assertThat(tests.getTests(), IsIterableContaining.hasItem(new TestCase("defaultpackage.TestMe#testSecond")));
    }
}
Also used : ChangeManager(de.dagere.peass.dependency.ChangeManager) FakeFileIterator(de.dagere.peass.dependencytests.helper.FakeFileIterator) TestCase(de.dagere.peass.dependency.analysis.data.TestCase) GitUtils(de.dagere.peass.vcs.GitUtils) DependencyReader(de.dagere.peass.dependency.reader.DependencyReader) VersionIterator(de.dagere.peass.vcs.VersionIterator) ExecutionConfig(de.dagere.peass.config.ExecutionConfig) TestSet(de.dagere.peass.dependency.analysis.data.TestSet) Test(org.junit.jupiter.api.Test)

Example 29 with TestCase

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

the class TestNonIncludedTestRemover method testWithSetOnlyExclude.

@Test
public void testWithSetOnlyExclude() {
    Set<TestCase> tests = new HashSet<TestCase>();
    tests.add(new TestCase("TestA", "method1"));
    tests.add(new TestCase("TestA", "method2"));
    tests.add(new TestCase("TestB", "method3"));
    tests.add(new TestCase("TestC", null));
    tests.add(new TestCase("TestD", null));
    ExecutionConfig executionConfig = new ExecutionConfig(Arrays.asList(new String[] {}), "test");
    executionConfig.setExcludes(Arrays.asList(new String[] { "TestA#*" }));
    NonIncludedTestRemover.removeNotIncluded(tests, executionConfig);
    Assert.assertEquals(3, tests.size());
}
Also used : TestCase(de.dagere.peass.dependency.analysis.data.TestCase) ExecutionConfig(de.dagere.peass.config.ExecutionConfig) HashSet(java.util.HashSet) Test(org.junit.jupiter.api.Test)

Example 30 with TestCase

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

the class TestNonIncludedTestRemover method testWithTestSet.

@Test
public void testWithTestSet() {
    TestSet tests = new TestSet();
    tests.addTest(new TestCase("TestA", "method1"));
    tests.addTest(new TestCase("TestA", "method2"));
    tests.addTest(new TestCase("TestB", "method3"));
    tests.addTest(new TestCase("TestC", null));
    tests.addTest(new TestCase("TestD", null));
    NonIncludedTestRemover.removeNotIncluded(tests, new ExecutionConfig(Arrays.asList(new String[] { "TestA#method1", "TestC" }), "test"));
    Assert.assertEquals(2, tests.getTests().size());
}
Also used : TestCase(de.dagere.peass.dependency.analysis.data.TestCase) ExecutionConfig(de.dagere.peass.config.ExecutionConfig) TestSet(de.dagere.peass.dependency.analysis.data.TestSet) Test(org.junit.jupiter.api.Test)

Aggregations

TestCase (de.dagere.peass.dependency.analysis.data.TestCase)163 File (java.io.File)66 Test (org.junit.jupiter.api.Test)57 TestSet (de.dagere.peass.dependency.analysis.data.TestSet)44 ChangedEntity (de.dagere.peass.dependency.analysis.data.ChangedEntity)25 ExecutionConfig (de.dagere.peass.config.ExecutionConfig)23 MeasurementConfig (de.dagere.peass.config.MeasurementConfig)22 PeassFolders (de.dagere.peass.folders.PeassFolders)18 HashSet (java.util.HashSet)17 List (java.util.List)14 LinkedList (java.util.LinkedList)13 EnvironmentVariables (de.dagere.peass.execution.utils.EnvironmentVariables)12 Map (java.util.Map)12 Kopemedata (de.dagere.kopeme.generated.Kopemedata)11 IOException (java.io.IOException)10 Set (java.util.Set)10 VersionStaticSelection (de.dagere.peass.dependency.persistence.VersionStaticSelection)9 Result (de.dagere.kopeme.generated.Result)8 ExecutionData (de.dagere.peass.dependency.persistence.ExecutionData)8 InitialDependency (de.dagere.peass.dependency.persistence.InitialDependency)8