use of org.evosuite.testcarver.extraction.CarvingManager in project evosuite by EvoSuite.
the class ObjectPoolManager method initialisePool.
public void initialisePool() {
if (!Properties.OBJECT_POOLS.isEmpty()) {
String[] poolFiles = Properties.OBJECT_POOLS.split(File.pathSeparator);
if (poolFiles.length > 1)
LoggingUtils.getEvoLogger().info("* Reading object pools:");
else
LoggingUtils.getEvoLogger().info("* Reading object pool:");
for (String fileName : poolFiles) {
logger.info("Adding object pool from file " + fileName);
ObjectPool pool = ObjectPool.getPoolFromFile(fileName);
if (pool == null) {
logger.error("Failed to load object from " + fileName);
} else {
LoggingUtils.getEvoLogger().info(" - Object pool " + fileName + ": " + pool.getNumberOfSequences() + " sequences for " + pool.getNumberOfClasses() + " classes");
addPool(pool);
}
}
if (logger.isDebugEnabled()) {
for (GenericClass key : pool.keySet()) {
logger.debug("Have sequences for " + key + ": " + pool.get(key).size());
}
}
}
if (Properties.CARVE_OBJECT_POOL) {
CarvingManager manager = CarvingManager.getInstance();
for (Class<?> targetClass : manager.getClassesWithTests()) {
List<TestCase> tests = manager.getTestsForClass(targetClass);
logger.info("Carved tests for {}: {}", targetClass.getName(), tests.size());
GenericClass cut = new GenericClass(targetClass);
for (TestCase test : tests) {
this.addSequence(cut, test);
}
}
logger.info("Pool after carving: " + this.getNumberOfClasses() + "/" + this.getNumberOfSequences());
}
}
use of org.evosuite.testcarver.extraction.CarvingManager in project evosuite by EvoSuite.
the class JUnitTestCarvedChromosomeFactory method readTestCases.
private void readTestCases() throws IllegalStateException {
CarvingManager manager = CarvingManager.getInstance();
final Class<?> targetClass = Properties.getTargetClassAndDontInitialise();
List<TestCase> tests = manager.getTestsForClass(targetClass);
junitTests.addAll(tests);
if (junitTests.size() > 0) {
totalNumberOfTestsCarved = junitTests.size();
LoggingUtils.getEvoLogger().info("* Using {} carved tests from existing JUnit tests for seeding", junitTests.size());
if (logger.isDebugEnabled()) {
for (TestCase test : junitTests) {
logger.debug("Carved Test: {}", test.toCode());
}
}
TestSuiteChromosome suite = new TestSuiteChromosome();
for (TestCase test : junitTests) {
suite.addTest(test);
}
for (Properties.Criterion pc : Properties.CRITERION) {
TestSuiteFitnessFunction f = FitnessFunctions.getFitnessFunction(pc);
f.getFitness(suite);
}
carvedCoverage = suite.getCoverage();
}
ClientNodeLocal client = ClientServices.getInstance().getClientNode();
client.trackOutputVariable(RuntimeVariable.CarvedTests, totalNumberOfTestsCarved);
client.trackOutputVariable(RuntimeVariable.CarvedCoverage, carvedCoverage);
}
Aggregations