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()) });
}
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);
});
}
}
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);
}
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);
}
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);
}
}
Aggregations