use of org.evosuite.EvoSuite in project evosuite by EvoSuite.
the class MockTcpSystemTest method testSendTcp.
@Test
public void testSendTcp() {
EvoSuite evosuite = new EvoSuite();
String targetClass = SendTcp.class.getCanonicalName();
Properties.TARGET_CLASS = targetClass;
Properties.SEARCH_BUDGET = 20000;
Properties.VIRTUAL_NET = true;
String[] command = new String[] { "-generateSuite", "-class", targetClass };
Object result = evosuite.parseCommandLine(command);
Assert.assertTrue(result != null);
GeneticAlgorithm<?> ga = getGAFromResult(result);
TestSuiteChromosome best = (TestSuiteChromosome) ga.getBestIndividual();
System.out.println("EvolvedTestSuite:\n" + best);
// assuming single fitness function
int goals = TestGenerationStrategy.getFitnessFactories().get(0).getCoverageGoals().size();
Assert.assertEquals("Wrong number of goals: ", 3, goals);
Assert.assertEquals("Non-optimal coverage: ", 1d, best.getCoverage(), 0.001);
}
use of org.evosuite.EvoSuite in project evosuite by EvoSuite.
the class MockTcpSystemTest method testReceiveTcp.
@Test
public void testReceiveTcp() {
EvoSuite evosuite = new EvoSuite();
String targetClass = ReceiveTcp.class.getCanonicalName();
Properties.TARGET_CLASS = targetClass;
Properties.SEARCH_BUDGET = 200_000;
Properties.VIRTUAL_NET = true;
String[] command = new String[] { "-generateSuite", "-class", targetClass };
Object result = evosuite.parseCommandLine(command);
Assert.assertTrue(result != null);
GeneticAlgorithm<?> ga = getGAFromResult(result);
TestSuiteChromosome best = (TestSuiteChromosome) ga.getBestIndividual();
System.out.println("EvolvedTestSuite:\n" + best);
// assuming single fitness function
int goals = TestGenerationStrategy.getFitnessFactories().get(0).getCoverageGoals().size();
Assert.assertEquals("Wrong number of goals: ", 3, goals);
Assert.assertEquals("Non-optimal coverage: ", 1d, best.getCoverage(), 0.001);
}
use of org.evosuite.EvoSuite in project evosuite by EvoSuite.
the class MockUrlSystemTest method testCheckResource.
@Test
public void testCheckResource() {
EvoSuite evosuite = new EvoSuite();
String targetClass = ReadFromURL.class.getCanonicalName();
Properties.TARGET_CLASS = targetClass;
Properties.SEARCH_BUDGET = 20000;
Properties.VIRTUAL_NET = true;
Properties.MAX_LOOP_ITERATIONS = 100000;
String[] command = new String[] { "-generateSuite", "-class", targetClass };
Object result = evosuite.parseCommandLine(command);
Assert.assertTrue(result != null);
GeneticAlgorithm<?> ga = getGAFromResult(result);
TestSuiteChromosome best = (TestSuiteChromosome) ga.getBestIndividual();
System.out.println("EvolvedTestSuite:\n" + best);
// assuming single fitness function
int goals = TestGenerationStrategy.getFitnessFactories().get(0).getCoverageGoals().size();
Assert.assertEquals("Wrong number of goals: ", 3, goals);
Assert.assertEquals("Non-optimal coverage: ", 1d, best.getCoverage(), 0.001);
}
use of org.evosuite.EvoSuite in project evosuite by EvoSuite.
the class MockInstantSystemTest method testInstant.
@Test
public void testInstant() throws Exception {
String targetClass = InstantExample.class.getCanonicalName();
Properties.TARGET_CLASS = targetClass;
Properties.JUNIT_TESTS = true;
Properties.JUNIT_CHECK = true;
Properties.REPLACE_CALLS = true;
Properties.OUTPUT_VARIABLES = "" + RuntimeVariable.HadUnstableTests;
EvoSuite evosuite = new EvoSuite();
String[] command = new String[] { "-generateSuite", "-class", targetClass };
Object result = evosuite.parseCommandLine(command);
GeneticAlgorithm<?> ga = getGAFromResult(result);
TestSuiteChromosome best = (TestSuiteChromosome) ga.getBestIndividual();
Assert.assertNotNull(best);
Assert.assertEquals("Non-optimal coverage: ", 1d, best.getCoverage(), 0.001);
checkUnstable();
}
use of org.evosuite.EvoSuite in project evosuite by EvoSuite.
the class RandomMethodSeedingTestSuiteChromosomeFactorySystemTest method setup.
@Before
public void setup() {
EvoSuite evosuite = new EvoSuite();
String targetClass = Class1.class.getCanonicalName();
Properties.TARGET_CLASS = targetClass;
String[] command = new String[] { "-generateSuite", "-class", targetClass };
Object result = evosuite.parseCommandLine(command);
ga = (GeneticAlgorithm<TestSuiteChromosome>) getGAFromResult(result);
bestIndividual = (TestSuiteChromosome) ga.getBestIndividual();
}
Aggregations