Search in sources :

Example 31 with TestSet

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

the class JmhTestTransformer method findModuleTests.

public TestSet findModuleTests(final ModuleClassMapping mapping, final List<String> includedModules, final File module) throws FileNotFoundException {
    TestSet moduleTests = new TestSet();
    ClazzFileFinder finder = new ClazzFileFinder(measurementConfig.getExecutionConfig());
    for (final String clazz : finder.getClasses(module)) {
        String currentModule = ModuleClassMapping.getModuleName(projectFolder, module);
        final List<TestCase> testMethodNames = getTestMethodNames(module, new TestCase(clazz, null, currentModule));
        for (TestCase test : testMethodNames) {
            if (includedModules == null || includedModules.contains(test.getModule())) {
                addTestIfIncluded(moduleTests, test);
            }
        }
    }
    return moduleTests;
}
Also used : TestCase(de.dagere.peass.dependency.analysis.data.TestCase) ClazzFileFinder(de.dagere.peass.dependency.ClazzFileFinder) TestSet(de.dagere.peass.dependency.analysis.data.TestSet)

Example 32 with TestSet

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

the class JmhTestTransformer method findModuleTests.

// TODO includedModules is currenctly ignored for jmh!
@Override
public TestSet findModuleTests(final ModuleClassMapping mapping, final List<String> includedModules, final ProjectModules modules) {
    TestSet allBenchmarks = new TestSet();
    try {
        for (File module : modules.getModules()) {
            TestSet moduleTests = findModuleTests(mapping, includedModules, module);
            allBenchmarks.addTestSet(moduleTests);
        }
    } catch (FileNotFoundException e) {
        throw new RuntimeException("File was not found, can not handle this error", e);
    }
    return allBenchmarks;
}
Also used : FileNotFoundException(java.io.FileNotFoundException) File(java.io.File) TestSet(de.dagere.peass.dependency.analysis.data.TestSet)

Example 33 with TestSet

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

the class JmhTestTransformer method buildTestMethodSet.

@Override
public TestSet buildTestMethodSet(final TestSet testsToUpdate, final List<File> modules) {
    final TestSet tests = new TestSet();
    for (final TestCase clazzname : testsToUpdate.getClasses()) {
        final Set<String> currentClazzMethods = testsToUpdate.getMethods(clazzname);
        if (currentClazzMethods == null || currentClazzMethods.isEmpty()) {
            final File moduleFolder = new File(projectFolder, clazzname.getModule());
            final List<TestCase> methods = getTestMethodNames(moduleFolder, clazzname);
            for (final TestCase test : methods) {
                addTestIfIncluded(tests, test);
            }
        } else {
            for (final String method : currentClazzMethods) {
                TestCase test = new TestCase(clazzname.getClazz(), method, clazzname.getModule());
                tests.addTest(test);
            }
        }
    }
    return tests;
}
Also used : TestCase(de.dagere.peass.dependency.analysis.data.TestCase) File(java.io.File) TestSet(de.dagere.peass.dependency.analysis.data.TestSet)

Example 34 with TestSet

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

the class TestBenchmarkDetection method testBenchmarkDetectionInnerClass.

@Test
public void testBenchmarkDetectionInnerClass() throws FileNotFoundException, IOException, XmlPullParserException {
    JmhTestTransformer jmhTransformer = new JmhTestTransformer(JmhTestConstants.INNER_CLASS_VERSION, JMH_CONFIG);
    ProjectModules modules = new ProjectModules(JmhTestConstants.INNER_CLASS_VERSION);
    TestSet tests = jmhTransformer.findModuleTests(new ModuleClassMapping(JmhTestConstants.INNER_CLASS_VERSION, modules, new ExecutionConfig()), null, modules);
    Assert.assertEquals(tests.getTests().size(), 1);
    TestCase test = tests.getTests().iterator().next();
    Assert.assertEquals("de.dagere.peass.ExampleBenchmark#testMethod", test.getExecutable());
}
Also used : JmhTestTransformer(de.dagere.peass.dependency.jmh.JmhTestTransformer) ProjectModules(de.dagere.peass.execution.utils.ProjectModules) TestCase(de.dagere.peass.dependency.analysis.data.TestCase) ModuleClassMapping(de.dagere.peass.dependency.analysis.ModuleClassMapping) ExecutionConfig(de.dagere.peass.config.ExecutionConfig) TestSet(de.dagere.peass.dependency.analysis.data.TestSet) Test(org.junit.jupiter.api.Test)

Example 35 with TestSet

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

the class TestCreateMeasurementExecutionScript method buildExecutionDataWithTests.

private ExecutionData buildExecutionDataWithTests() {
    StaticTestSelection dependencies = TestExecutionData.buildExampleDependencies();
    VersionStaticSelection version2 = dependencies.getVersions().get("000002");
    version2.getChangedClazzes().put(new ChangedEntity("Test1#testMe"), new TestSet(new TestCase("Test1#testMe")));
    VersionStaticSelection version5 = dependencies.getVersions().get("000005");
    version5.getChangedClazzes().put(new ChangedEntity("Test5#testMe"), new TestSet(new TestCase("Test5#testMe")));
    ExecutionData executiondata = new ExecutionData(dependencies);
    return executiondata;
}
Also used : TestCase(de.dagere.peass.dependency.analysis.data.TestCase) VersionStaticSelection(de.dagere.peass.dependency.persistence.VersionStaticSelection) ChangedEntity(de.dagere.peass.dependency.analysis.data.ChangedEntity) StaticTestSelection(de.dagere.peass.dependency.persistence.StaticTestSelection) TestSet(de.dagere.peass.dependency.analysis.data.TestSet) TestExecutionData(de.dagere.peass.dependency.persistence.TestExecutionData) ExecutionData(de.dagere.peass.dependency.persistence.ExecutionData)

Aggregations

TestSet (de.dagere.peass.dependency.analysis.data.TestSet)71 TestCase (de.dagere.peass.dependency.analysis.data.TestCase)41 File (java.io.File)19 ChangedEntity (de.dagere.peass.dependency.analysis.data.ChangedEntity)16 Test (org.junit.jupiter.api.Test)15 ExecutionConfig (de.dagere.peass.config.ExecutionConfig)12 VersionStaticSelection (de.dagere.peass.dependency.persistence.VersionStaticSelection)10 Set (java.util.Set)8 ExecutionData (de.dagere.peass.dependency.persistence.ExecutionData)7 Map (java.util.Map)7 ModuleClassMapping (de.dagere.peass.dependency.analysis.ModuleClassMapping)6 JsonIgnore (com.fasterxml.jackson.annotation.JsonIgnore)5 ChangeManager (de.dagere.peass.dependency.ChangeManager)5 StaticTestSelection (de.dagere.peass.dependency.persistence.StaticTestSelection)5 DependencyReader (de.dagere.peass.dependency.reader.DependencyReader)5 FakeFileIterator (de.dagere.peass.dependencytests.helper.FakeFileIterator)5 PeassFolders (de.dagere.peass.folders.PeassFolders)5 VersionIterator (de.dagere.peass.vcs.VersionIterator)5 JmhTestTransformer (de.dagere.peass.dependency.jmh.JmhTestTransformer)4 LinkedHashMap (java.util.LinkedHashMap)4