Search in sources :

Example 76 with EvoSuite

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

the class StaticInitThrowsNullPointerSystemTest method testWithNoReset.

/*
	 * These tests are based on issues found on project 44_summa, which is using the lucene API.
	 * those have issues when for example classes uses org.apache.lucene.util.Constants which has:
	 * 
	  try {
	    Collections.class.getMethod("emptySortedSet");
	  } catch (NoSuchMethodException nsme) {
	    v8 = false;
	  }
	  *
	  * in its static initializer
	 */
@Test
public void testWithNoReset() {
    Properties.RESET_STATIC_FIELDS = false;
    EvoSuite evosuite = new EvoSuite();
    String targetClass = StaticInitThrowsNullPointer.class.getCanonicalName();
    Properties.TARGET_CLASS = targetClass;
    String[] command = new String[] { "-generateSuite", "-class", targetClass };
    Object result = evosuite.parseCommandLine(command);
    assertTrue(result instanceof List);
    List<?> list = (List<?>) result;
    assertEquals(0, list.size());
}
Also used : EvoSuite(org.evosuite.EvoSuite) List(java.util.List) Test(org.junit.Test)

Example 77 with EvoSuite

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

the class MockJOptionPaneSystemTest method testShowConfirmDialogs2.

@Test
public void testShowConfirmDialogs2() throws Exception {
    final String targetClass = AskUserShowConfirmDialogs2.class.getCanonicalName();
    Properties.TEST_ARCHIVE = false;
    Properties.CRITERION = new Properties.Criterion[] { Properties.Criterion.BRANCH };
    Properties.TARGET_CLASS = targetClass;
    Properties.REPLACE_GUI = true;
    Properties.MINIMIZE = true;
    // As mutation operators remove instrumentation. This needs fixing first
    Properties.ASSERTIONS = false;
    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);
    Assert.assertEquals("Non-optimal fitness: ", 0d, best.getFitness(), 0.001);
}
Also used : EvoSuite(org.evosuite.EvoSuite) TestSuiteChromosome(org.evosuite.testsuite.TestSuiteChromosome) Properties(org.evosuite.Properties) Test(org.junit.Test)

Example 78 with EvoSuite

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

the class MockJOptionPaneSystemTest method testShowOptionDialogExample.

@Test
public void testShowOptionDialogExample() throws Exception {
    final String targetClass = AskUserShowOptionDialog.class.getCanonicalName();
    Properties.TEST_ARCHIVE = false;
    Properties.CRITERION = new Properties.Criterion[] { Properties.Criterion.BRANCH };
    Properties.TARGET_CLASS = targetClass;
    Properties.REPLACE_GUI = true;
    Properties.MINIMIZE = true;
    // As mutation operators remove instrumentation. This needs fixing first
    Properties.ASSERTIONS = false;
    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);
    Assert.assertEquals("Non-optimal fitness: ", 0d, best.getFitness(), 0.001);
}
Also used : EvoSuite(org.evosuite.EvoSuite) TestSuiteChromosome(org.evosuite.testsuite.TestSuiteChromosome) Properties(org.evosuite.Properties) Test(org.junit.Test)

Example 79 with EvoSuite

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

the class MockJOptionPaneSystemTest method testShowInputMultipleDialogs.

@Test
public void testShowInputMultipleDialogs() throws Exception {
    final String targetClass = AskUserShowInputDailogs.class.getCanonicalName();
    Properties.TEST_ARCHIVE = false;
    Properties.CRITERION = new Properties.Criterion[] { Properties.Criterion.BRANCH };
    Properties.TARGET_CLASS = targetClass;
    Properties.REPLACE_GUI = true;
    Properties.MINIMIZE = true;
    // As mutation operators remove instrumentation. This needs fixing first
    Properties.ASSERTIONS = false;
    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);
    Assert.assertEquals("Non-optimal fitness: ", 0d, best.getFitness(), 0.001);
}
Also used : EvoSuite(org.evosuite.EvoSuite) TestSuiteChromosome(org.evosuite.testsuite.TestSuiteChromosome) Properties(org.evosuite.Properties) Test(org.junit.Test)

Example 80 with EvoSuite

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

the class MockJOptionPaneSystemTest method testShowConfirmDialogs0.

@Test
public void testShowConfirmDialogs0() throws Exception {
    final String targetClass = AskUserShowConfirmDialogs0.class.getCanonicalName();
    Properties.TEST_ARCHIVE = false;
    Properties.CRITERION = new Properties.Criterion[] { Properties.Criterion.BRANCH };
    Properties.TARGET_CLASS = targetClass;
    Properties.REPLACE_GUI = true;
    Properties.MINIMIZE = true;
    // As mutation operators remove instrumentation. This needs fixing first
    Properties.ASSERTIONS = false;
    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);
    Assert.assertEquals("Non-optimal fitness: ", 0d, best.getFitness(), 0.001);
}
Also used : EvoSuite(org.evosuite.EvoSuite) TestSuiteChromosome(org.evosuite.testsuite.TestSuiteChromosome) Properties(org.evosuite.Properties) Test(org.junit.Test)

Aggregations

EvoSuite (org.evosuite.EvoSuite)462 Test (org.junit.Test)410 TestSuiteChromosome (org.evosuite.testsuite.TestSuiteChromosome)391 Properties (org.evosuite.Properties)86 OutputVariable (org.evosuite.statistics.OutputVariable)61 GenericSUTString (com.examples.with.different.packagename.generic.GenericSUTString)49 SearchStatistics (org.evosuite.statistics.SearchStatistics)16 Ignore (org.junit.Ignore)15 CheapPurityAnalyzer (org.evosuite.assertion.CheapPurityAnalyzer)13 CSVReader (com.opencsv.CSVReader)12 FileReader (java.io.FileReader)12 File (java.io.File)9 TestCase (org.evosuite.testcase.TestCase)8 ArrayList (java.util.ArrayList)7 List (java.util.List)7 MethodCoverageFitnessFunctionSystemTest (org.evosuite.coverage.method.MethodCoverageFitnessFunctionSystemTest)7 Before (org.junit.Before)7 TypeSeedingExampleString (com.examples.with.different.packagename.TypeSeedingExampleString)6 TestGenerationResult (org.evosuite.result.TestGenerationResult)6 CalculatorTest (com.examples.with.different.packagename.CalculatorTest)5