use of org.evosuite.continuous.project.ProjectAnalyzer in project evosuite by EvoSuite.
the class JobSchedulerTest method testSeedingOrder.
@Test
public void testSeedingOrder() {
String[] cuts = new String[] { Simple.class.getName(), UsingSimpleAndTrivial.class.getName(), Trivial.class.getName() };
ProjectAnalyzer analyzer = new ProjectAnalyzer(cuts);
ProjectStaticData data = analyzer.analyze();
int cores = 3;
int memory = 1800;
int budget = 2;
CtgConfiguration conf = new CtgConfiguration(memory, cores, budget, 1, false, AvailableSchedule.SEEDING);
JobScheduler scheduler = new JobScheduler(data, conf);
List<JobDefinition> jobs = scheduler.createNewSchedule();
Assert.assertNotNull(jobs);
Assert.assertEquals("Wrong number of jobs: " + jobs.toString(), 3, jobs.size());
// UsingSimpleAndTrivial should be the last in the schedule, as it depends on the first 2
JobDefinition seeding = jobs.get(2);
Assert.assertNotNull(seeding);
Assert.assertEquals(UsingSimpleAndTrivial.class.getName(), seeding.cut);
Set<String> in = seeding.inputClasses;
Assert.assertNotNull(in);
System.out.println(in.toString());
Assert.assertTrue(in.contains(Simple.class.getName()));
Assert.assertTrue(in.contains(Trivial.class.getName()));
Assert.assertEquals(2, in.size());
}
use of org.evosuite.continuous.project.ProjectAnalyzer in project evosuite by EvoSuite.
the class ContinuousTestGeneration method execute.
/**
* Apply CTG, and return a string with some summary
*
* @return
*/
public String execute() {
// init the local storage manager
StorageManager storage = new StorageManager();
if (!storage.isStorageOk()) {
return "Failed to initialize local storage system";
}
if (Properties.CTG_DELETE_OLD_TMP_FOLDERS) {
storage.deleteAllOldTmpFolders();
}
if (!storage.createNewTmpFolders()) {
return "Failed to create tmp folders";
}
// check project
ProjectAnalyzer analyzer = new ProjectAnalyzer(target, prefix, cuts);
ProjectStaticData data = analyzer.analyze();
if (data.getTotalNumberOfTestableCUTs() == 0) {
return "There is no class to test in the chosen project\n" + "Target: " + target + "\n" + "Prefix: '" + prefix + "'\n";
}
if (Properties.CTG_DEBUG_PORT != null && data.getTotalNumberOfTestableCUTs() != 1) {
throw new IllegalStateException("Cannot debug CTG when more than one CUT is selected");
}
if (Properties.CTG_TIME_PER_CLASS != null) {
configuration = configuration.getWithChangedTime(Properties.CTG_TIME_PER_CLASS, data.getTotalNumberOfTestableCUTs());
}
JobScheduler scheduler = new JobScheduler(data, configuration);
JobExecutor executor = new JobExecutor(storage, projectClassPath, configuration);
// loop: define (partial) schedule
while (scheduler.canExecuteMore()) {
List<JobDefinition> jobs = scheduler.createNewSchedule();
executor.executeJobs(jobs, configuration.getNumberOfUsableCores());
executor.waitForJobs();
}
String description = storage.mergeAndCommitChanges(data, cuts);
if (exportFolder != null) {
try {
exportToFolder(".", exportFolder);
} catch (IOException e) {
return "Failed to export tests: " + e.getMessage();
}
}
// call home
if (configuration.callHome) {
// TODO
}
return description;
}
Aggregations