Search in sources :

Example 11 with TestGenerationResult

use of org.evosuite.result.TestGenerationResult in project evosuite by EvoSuite.

the class AmbiguityFitnessSystemTest method testZeroAmbiguityScore.

@Test
public void testZeroAmbiguityScore() {
    EvoSuite evosuite = new EvoSuite();
    String targetClass = Compositional.class.getCanonicalName();
    Properties.TARGET_CLASS = targetClass;
    String[] command = new String[] { "-class", targetClass, "-generateSuite" };
    List<List<TestGenerationResult>> result = (List<List<TestGenerationResult>>) evosuite.parseCommandLine(command);
    Assert.assertNotNull(result);
    List<?> goals = AmbiguityCoverageFactory.getGoals();
    assertEquals(12, goals.size());
    GeneticAlgorithm<?> ga = result.get(0).get(0).getGeneticAlgorithm();
    Assert.assertNotNull(ga);
    assertEquals(0.0, ga.getBestIndividual().getFitnessInstanceOf(AmbiguityCoverageSuiteFitness.class), 0.0);
}
Also used : TestGenerationResult(org.evosuite.result.TestGenerationResult) EvoSuite(org.evosuite.EvoSuite) List(java.util.List) Test(org.junit.Test)

Example 12 with TestGenerationResult

use of org.evosuite.result.TestGenerationResult in project evosuite by EvoSuite.

the class AmbiguityFitnessSystemTest method testZeroAmbiguityScoreWithPreviousCoverage.

@Test
public void testZeroAmbiguityScoreWithPreviousCoverage() {
    EvoSuite evosuite = new EvoSuite();
    String targetClass = Compositional.class.getCanonicalName();
    Properties.TARGET_CLASS = targetClass;
    String previous_tmp_coverage = "1 1 1 1 1 1 1 1 1 1 1 +\n" + "1 1 1 1 0 0 0 0 0 0 0 -\n";
    this.writeMatrix(previous_tmp_coverage);
    Properties.USE_EXISTING_COVERAGE = true;
    String[] command = new String[] { "-class", targetClass, "-generateSuite" };
    List<List<TestGenerationResult>> result = (List<List<TestGenerationResult>>) evosuite.parseCommandLine(command);
    Assert.assertNotNull(result);
    List<?> goals = AmbiguityCoverageFactory.getGoals();
    assertEquals(12, goals.size());
    GeneticAlgorithm<?> ga = result.get(0).get(0).getGeneticAlgorithm();
    Assert.assertNotNull(ga);
    assertEquals(0.0, ga.getBestIndividual().getFitnessInstanceOf(AmbiguityCoverageSuiteFitness.class), 0.0);
}
Also used : TestGenerationResult(org.evosuite.result.TestGenerationResult) EvoSuite(org.evosuite.EvoSuite) List(java.util.List) Test(org.junit.Test)

Example 13 with TestGenerationResult

use of org.evosuite.result.TestGenerationResult in project evosuite by EvoSuite.

the class TestShouldNotWorkSystemTest method testJavaPackageNotOnProjectCP.

@SuppressWarnings("unchecked")
@Test
public void testJavaPackageNotOnProjectCP() {
    EvoSuite evosuite = new EvoSuite();
    String targetClass = java.util.TreeMap.class.getCanonicalName();
    Properties.TARGET_CLASS = targetClass;
    String[] command = new String[] { "-generateSuite", "-class", targetClass };
    Object result = evosuite.parseCommandLine(command);
    // List<TestGenerationResult> results = (List<TestGenerationResult>)result;
    List<List<TestGenerationResult>> results = (List<List<TestGenerationResult>>) result;
    assertEquals(1, results.size());
    // TestGenerationResult testResult = results.iterator().next();
    TestGenerationResult testResult = results.get(0).get(0);
    System.out.println(testResult.getErrorMessage());
    assertFalse(testResult.getErrorMessage().isEmpty());
    assertEquals(TestGenerationResult.Status.ERROR, testResult.getTestGenerationStatus());
}
Also used : TestGenerationResult(org.evosuite.result.TestGenerationResult) EvoSuite(org.evosuite.EvoSuite) List(java.util.List) Test(org.junit.Test)

Aggregations

TestGenerationResult (org.evosuite.result.TestGenerationResult)13 List (java.util.List)6 EvoSuite (org.evosuite.EvoSuite)6 Test (org.junit.Test)5 ArrayList (java.util.ArrayList)4 ResourceList (org.evosuite.classpath.ResourceList)4 File (java.io.File)3 IOException (java.io.IOException)2 CoreException (org.eclipse.core.runtime.CoreException)2 JavaModelException (org.eclipse.jdt.core.JavaModelException)2 PartInitException (org.eclipse.ui.PartInitException)2 TestSuiteChromosome (org.evosuite.testsuite.TestSuiteChromosome)2 FileNotFoundException (java.io.FileNotFoundException)1 RemoteException (java.rmi.RemoteException)1 HashMap (java.util.HashMap)1 Vector (java.util.Vector)1 IFile (org.eclipse.core.resources.IFile)1 IPath (org.eclipse.core.runtime.IPath)1 Path (org.eclipse.core.runtime.Path)1 ICompilationUnit (org.eclipse.jdt.core.ICompilationUnit)1