Search in sources :

Example 1 with TestCase

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

the class ReadProperties method detectVersionProperty.

private int detectVersionProperty(final File projectFolder, final File viewFolder, final BufferedWriter csvWriter, final VersionChangeProperties versionProperties, final Entry<String, Changes> versionChanges, final String predecessor, final ExecutionData data) throws IOException, JsonGenerationException, JsonMappingException {
    final File methodFolder = new File(out.getParentFile(), "methods");
    methodFolder.mkdirs();
    final String version = versionChanges.getKey();
    final ChangeProperties changeProperties = new ChangeProperties();
    changeProperties.setCommitText(GitUtils.getCommitText(projectFolder, version));
    changeProperties.setCommitter(GitUtils.getCommitter(projectFolder, version));
    versionProperties.getVersions().put(version, changeProperties);
    int count = 0;
    for (final Entry<String, List<Change>> changes : versionChanges.getValue().getTestcaseChanges().entrySet()) {
        final String testclazz = changes.getKey();
        String module = null;
        for (TestCase test : data.getVersions().get(versionChanges.getKey()).getTests()) {
            if (test.getClazz().equals(testclazz)) {
                module = test.getModule();
            }
        }
        final List<ChangeProperty> properties = new LinkedList<>();
        changeProperties.getProperties().put(testclazz, properties);
        for (final Change testcaseChange : changes.getValue()) {
            ExecutionConfig config = new ExecutionConfig();
            config.setVersion(version);
            config.setVersionOld(predecessor);
            ChangedEntity entity = new ChangedEntity(testclazz, module);
            final PropertyReadHelper reader = new PropertyReadHelper(config, entity, testcaseChange, projectFolder, viewFolder, methodFolder, null);
            final ChangeProperty currentProperty = reader.read();
            // if (currentProperty != null) {
            properties.add(currentProperty);
            Constants.OBJECTMAPPER.writeValue(out, versionProperties);
            writeCSVLine(csvWriter, currentProperty, projectFolder.getName());
            // }
            count++;
        }
    }
    return count;
}
Also used : PropertyReadHelper(de.dagere.peass.analysis.properties.PropertyReadHelper) ChangeProperty(de.dagere.peass.analysis.properties.ChangeProperty) ChangedEntity(de.dagere.peass.dependency.analysis.data.ChangedEntity) Change(de.dagere.peass.analysis.changes.Change) ExecutionConfig(de.dagere.peass.config.ExecutionConfig) LinkedList(java.util.LinkedList) TestCase(de.dagere.peass.dependency.analysis.data.TestCase) ChangeProperties(de.dagere.peass.analysis.properties.ChangeProperties) VersionChangeProperties(de.dagere.peass.analysis.properties.VersionChangeProperties) LinkedList(java.util.LinkedList) List(java.util.List) File(java.io.File)

Example 2 with TestCase

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

the class ChangeReader method getIsChange.

public void getIsChange(final String fileName, final Kopemedata data, final ProjectChanges changeKnowledge, final ProjectStatistics info, final String[] versions, final DescribedChunk describedChunk) {
    LOG.debug(data.getTestcases().getClazz());
    final TestcaseStatistic statistic = describedChunk.getStatistic(config);
    statistic.setPredecessor(versions[0]);
    // if (! (statistic.getTvalue() == Double.NaN)){
    CompareData cd = new CompareData(describedChunk.getPrevious(), describedChunk.getCurrent());
    final Relation confidenceResult = ConfidenceIntervalInterpretion.compare(cd);
    final TestCase testcase = getTestcase(data, versions, describedChunk);
    final double diff = describedChunk.getDiff();
    final boolean isBigEnoughDiff = Math.abs(diff) > minChange;
    allData.addStatistic(versions[1], testcase, fileName, statistic, statistic.isChange() && isBigEnoughDiff, !confidenceResult.equals(Relation.EQUAL));
    if (statistic.isChange() && isBigEnoughDiff) {
        changeKnowledge.addChange(testcase, versions[1], confidenceResult, statistic.isChange() ? Relation.GREATER_THAN : Relation.EQUAL, describedChunk.getDescPrevious().getMean(), diff, statistic.getTvalue(), statistic.getVMs());
        writeRunCommands(versions, describedChunk, testcase);
    }
    info.addMeasurement(versions[1], testcase, statistic);
}
Also used : TestcaseStatistic(de.dagere.peass.measurement.statistics.data.TestcaseStatistic) CompareData(de.dagere.peass.measurement.statistics.bimodal.CompareData) Relation(de.dagere.peass.measurement.statistics.Relation) TestCase(de.dagere.peass.dependency.analysis.data.TestCase)

Example 3 with TestCase

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

the class ContinuousDependencyReader method getTests.

public RTSResult getTests(final VersionIterator iterator, final String url, final String version, final MeasurementConfig measurementConfig) {
    final StaticTestSelection dependencies = getDependencies(iterator, url);
    RTSResult result;
    final Set<TestCase> tests;
    if (dependencies.getVersions().size() > 0) {
        VersionStaticSelection versionInfo = dependencies.getVersions().get(version);
        LOG.debug("Versioninfo for version {}, running was: {}", version, versionInfo != null ? versionInfo.isRunning() : "null");
        if (dependencyConfig.isGenerateTraces()) {
            tests = selectResults(version);
            result = new RTSResult(tests, versionInfo.isRunning());
        } else {
            tests = versionInfo.getTests().getTests();
            result = new RTSResult(tests, versionInfo.isRunning());
        }
        // final Set<TestCase> tests = selectIncludedTests(dependencies);
        NonIncludedTestRemover.removeNotIncluded(tests, measurementConfig.getExecutionConfig());
    } else {
        tests = new HashSet<>();
        result = new RTSResult(tests, true);
        LOG.info("No test executed - version did not contain changed tests.");
    }
    return result;
}
Also used : TestCase(de.dagere.peass.dependency.analysis.data.TestCase) VersionStaticSelection(de.dagere.peass.dependency.persistence.VersionStaticSelection) StaticTestSelection(de.dagere.peass.dependency.persistence.StaticTestSelection)

Example 4 with TestCase

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

the class ContinuousDependencyReader method selectResults.

private Set<TestCase> selectResults(final String version) {
    try {
        final Set<TestCase> tests;
        if (dependencyConfig.isGenerateCoverageSelection()) {
            LOG.info("Using coverage-based test selection");
            ExecutionData executionData = Constants.OBJECTMAPPER.readValue(resultsFolders.getCoverageSelectionFile(), ExecutionData.class);
            tests = fetchTestset(version, executionData);
        } else {
            LOG.info("Using dynamic test selection results");
            ExecutionData executionData = Constants.OBJECTMAPPER.readValue(resultsFolders.getTraceTestSelectionFile(), ExecutionData.class);
            tests = fetchTestset(version, executionData);
        }
        return tests;
    } catch (IOException e) {
        throw new RuntimeException(e);
    }
}
Also used : TestCase(de.dagere.peass.dependency.analysis.data.TestCase) IOException(java.io.IOException) ExecutionData(de.dagere.peass.dependency.persistence.ExecutionData)

Example 5 with TestCase

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

the class CopyFromFull method checkFileMerging.

public static void checkFileMerging(final File goal, final ExecutionData tests, final File source) throws JAXBException {
    Kopemedata kopemeData = XMLDataLoader.loadData(source);
    Testcases testcase = kopemeData.getTestcases();
    TestcaseType testcaseType = testcase.getTestcase().get(0);
    String clazz = testcase.getClazz();
    String method = testcaseType.getName();
    TestCase testcase2 = new TestCase(testcase);
    List<Chunk> chunks = testcaseType.getDatacollector().get(0).getChunk();
    if (!goal.exists()) {
        goal.mkdirs();
    }
    for (Chunk chunk : chunks) {
        checkChunkMerging(goal, tests, testcase2, chunk);
    }
}
Also used : TestCase(de.dagere.peass.dependency.analysis.data.TestCase) TestcaseType(de.dagere.kopeme.generated.TestcaseType) Testcases(de.dagere.kopeme.generated.Kopemedata.Testcases) Kopemedata(de.dagere.kopeme.generated.Kopemedata) Chunk(de.dagere.kopeme.generated.TestcaseType.Datacollector.Chunk)

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