Search in sources :

Example 96 with EvoSuite

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

the class MockLocalDateSystemTest method testLocalDate.

@Test
public void testLocalDate() throws Exception {
    String targetClass = LocalDateExample.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();
}
Also used : EvoSuite(org.evosuite.EvoSuite) TestSuiteChromosome(org.evosuite.testsuite.TestSuiteChromosome) Test(org.junit.Test)

Example 97 with EvoSuite

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

the class PreferencesSystemTest method testSystemPreferences.

@Test
public void testSystemPreferences() throws Exception {
    String targetClass = PrefsSystem.class.getCanonicalName();
    Properties.TARGET_CLASS = targetClass;
    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();
    System.out.println(best.toString());
    Assert.assertNotNull(best);
    Assert.assertEquals("Non-optimal coverage: ", 1d, best.getCoverage(), 0.001);
}
Also used : EvoSuite(org.evosuite.EvoSuite) TestSuiteChromosome(org.evosuite.testsuite.TestSuiteChromosome) Test(org.junit.Test)

Example 98 with EvoSuite

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

the class PreferencesSystemTest method testNodePreferences.

@Test
public void testNodePreferences() throws Exception {
    String targetClass = PrefsNode.class.getCanonicalName();
    Properties.TARGET_CLASS = targetClass;
    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();
    System.out.println(best.toString());
    Assert.assertNotNull(best);
    Assert.assertEquals("Non-optimal coverage: ", 1d, best.getCoverage(), 0.001);
}
Also used : EvoSuite(org.evosuite.EvoSuite) TestSuiteChromosome(org.evosuite.testsuite.TestSuiteChromosome) Test(org.junit.Test)

Example 99 with EvoSuite

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

the class PreferencesSystemTest method testUserPreferences.

@Test
public void testUserPreferences() throws Exception {
    String targetClass = PrefsUser.class.getCanonicalName();
    Properties.TARGET_CLASS = targetClass;
    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();
    System.out.println(best.toString());
    Assert.assertNotNull(best);
    Assert.assertEquals("Non-optimal coverage: ", 1d, best.getCoverage(), 0.001);
}
Also used : EvoSuite(org.evosuite.EvoSuite) TestSuiteChromosome(org.evosuite.testsuite.TestSuiteChromosome) Test(org.junit.Test)

Example 100 with EvoSuite

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

the class RandomCallSystemTest method testRandomCall.

@Test
public void testRandomCall() {
    EvoSuite evosuite = new EvoSuite();
    String targetClass = RandomBranch.class.getCanonicalName();
    Properties.TARGET_CLASS = targetClass;
    Properties.REPLACE_CALLS = true;
    // , "-Dassertions=true"
    String[] command = new String[] { "-generateSuite", "-class", targetClass };
    Object result = evosuite.parseCommandLine(command);
    GeneticAlgorithm<?> ga = getGAFromResult(result);
    TestSuiteChromosome best = (TestSuiteChromosome) ga.getBestIndividual();
    // assuming single fitness function
    int goals = TestGenerationStrategy.getFitnessFactories().get(0).getCoverageGoals().size();
    Assert.assertEquals("Wrong number of goals: ", 5, goals);
    Assert.assertEquals("Non-optimal coverage: ", 1d, best.getCoverage(), 0.001);
}
Also used : EvoSuite(org.evosuite.EvoSuite) TestSuiteChromosome(org.evosuite.testsuite.TestSuiteChromosome) 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