Search in sources :

Example 1 with TestSuite

use of org.kanonizo.framework.objects.TestSuite in project kanonizo by kanonizo.

the class MiscStatsWriter method prepareCsv.

@Override
protected void prepareCsv() {
    TestSuite optimal = algorithm.getCurrentOptimal();
    setHeaders(new String[] { "Fitness", "Iterations", "Algorithm Execution Time", "Fitness Evaluations" });
    addRow(new String[] { Double.toString(optimal.getFitness()), Integer.toString(algorithm.getAge()), Long.toString(algorithm.getTotalTime()), Integer.toString(algorithm.getFitnessEvaluations()) });
}
Also used : TestSuite(org.kanonizo.framework.objects.TestSuite)

Example 2 with TestSuite

use of org.kanonizo.framework.objects.TestSuite in project kanonizo by kanonizo.

the class TestCaseOrderingWriter method prepareCsv.

@Override
protected void prepareCsv() {
    if (finalWrite) {
        TestSuite optimal = algorithm.getCurrentOptimal();
        optimal.getTestCases().forEach(testCase -> {
            String[] csv = new String[] { testCase.toString(), Long.toString(testCase.getExecutionTime()), Boolean.toString(!testCase.hasFailures()), stackTraceToString(testCase.getFailures()), Integer.toString(inst.getLinesCovered(testCase).size()) };
            addRow(csv);
        });
    }
}
Also used : TestSuite(org.kanonizo.framework.objects.TestSuite)

Example 3 with TestSuite

use of org.kanonizo.framework.objects.TestSuite in project kanonizo by kanonizo.

the class TestCasePrioritiser method generateSolution.

@Override
protected final void generateSolution() {
    TestSuite suite = problem.clone().getTestSuite();
    List<TestCase> testCases = suite.getTestCases();
    List<TestCase> orderedTestCases = new ArrayList<>();
    init(testCases);
    while (!testCases.isEmpty() && !shouldFinish()) {
        TestCase tc = selectTestCase(testCases);
        testCases.remove(tc);
        orderedTestCases.add(tc);
        fw.notifyTestCaseSelection(tc);
        fw.getDisplay().reportProgress(orderedTestCases.size(), testCases.size() + orderedTestCases.size());
    }
    if (!testCases.isEmpty()) {
        StoppingCondition terminatingStoppingCondition = stoppingConditions.stream().filter(cond -> cond.shouldFinish(this)).findFirst().get();
        logger.info("Algorithm terminated by " + terminatingStoppingCondition.getClass().getSimpleName());
        orderedTestCases.addAll(testCases);
    }
    suite.setTestCases(orderedTestCases);
    fw.getDisplay().fireTestSuiteChange(suite);
    setCurrentOptimal(suite);
}
Also used : TestSuite(org.kanonizo.framework.objects.TestSuite) StoppingCondition(org.kanonizo.algorithms.stoppingconditions.StoppingCondition) TestCase(org.kanonizo.framework.objects.TestCase) ArrayList(java.util.ArrayList)

Example 4 with TestSuite

use of org.kanonizo.framework.objects.TestSuite in project kanonizo by kanonizo.

the class TotalFEPAlgorithm method generateSolution.

@Override
protected void generateSolution() {
    TestSuite opt = getCurrentOptimal();
    Mutation.initialise(opt);
}
Also used : TestSuite(org.kanonizo.framework.objects.TestSuite)

Example 5 with TestSuite

use of org.kanonizo.framework.objects.TestSuite in project kanonizo by kanonizo.

the class GeneticAlgorithm method generateInitialPopulation.

protected void generateInitialPopulation() {
    logger.info("Generating initial population");
    for (int i = 0; i < POPULATION_SIZE; i++) {
        TestSuite clone = problem.clone().getTestSuite();
        List<Integer> testCaseOrdering = IntStream.range(0, clone.getTestCases().size()).collect(ArrayList::new, ArrayList::add, ArrayList::addAll);
        List<TestCase> randomOrdering = new ArrayList<TestCase>();
        while (!testCaseOrdering.isEmpty()) {
            int index = RandomInstance.nextInt(testCaseOrdering.size());
            TestCase tc = clone.getTestCases().get(testCaseOrdering.get(index));
            randomOrdering.add(tc);
            testCaseOrdering.remove(index);
        }
        clone.setTestCases(randomOrdering);
        population.add(clone);
    }
}
Also used : TestSuite(org.kanonizo.framework.objects.TestSuite) TestCase(org.kanonizo.framework.objects.TestCase) ArrayList(java.util.ArrayList)

Aggregations

TestSuite (org.kanonizo.framework.objects.TestSuite)11 TestCase (org.kanonizo.framework.objects.TestCase)5 ArrayList (java.util.ArrayList)4 Parameter (com.scythe.instrumenter.InstrumentationProperties.Parameter)1 ClassAnalyzer (com.scythe.instrumenter.analysis.ClassAnalyzer)1 File (java.io.File)1 FileNotFoundException (java.io.FileNotFoundException)1 FileReader (java.io.FileReader)1 IOException (java.io.IOException)1 HashMap (java.util.HashMap)1 List (java.util.List)1 Map (java.util.Map)1 Scanner (java.util.Scanner)1 Predicate (java.util.function.Predicate)1 Collectors (java.util.stream.Collectors)1 CSVFormat (org.apache.commons.csv.CSVFormat)1 CSVParser (org.apache.commons.csv.CSVParser)1 CSVRecord (org.apache.commons.csv.CSVRecord)1 StoppingCondition (org.kanonizo.algorithms.stoppingconditions.StoppingCondition)1 Display (org.kanonizo.display.Display)1