Search in sources :

Example 11 with OutputVariable

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

the class RuntimeUserSystemTest method testRuntimeUser.

@Test
public void testRuntimeUser() {
    EvoSuite evosuite = new EvoSuite();
    String targetClass = RuntimeUser.class.getCanonicalName();
    Properties.TARGET_CLASS = targetClass;
    Properties.OUTPUT_VARIABLES = "" + RuntimeVariable.HadUnstableTests;
    String[] command = new String[] { "-generateSuite", "-class", targetClass };
    Object result = evosuite.parseCommandLine(command);
    GeneticAlgorithm<?> ga = getGAFromResult(result);
    TestSuiteChromosome best = (TestSuiteChromosome) ga.getBestIndividual();
    System.out.println("EvolvedTestSuite:\n" + best);
    Map<String, OutputVariable<?>> map = DebugStatisticsBackend.getLatestWritten();
    Assert.assertNotNull(map);
    OutputVariable unstable = map.get(RuntimeVariable.HadUnstableTests.toString());
    Assert.assertNotNull(unstable);
    Assert.assertEquals(Boolean.FALSE, unstable.getValue());
}
Also used : EvoSuite(org.evosuite.EvoSuite) TestSuiteChromosome(org.evosuite.testsuite.TestSuiteChromosome) OutputVariable(org.evosuite.statistics.OutputVariable) Test(org.junit.Test)

Example 12 with OutputVariable

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

the class SingletonUserSystemTest method testTypeErasure.

@Test
public void testTypeErasure() {
    EvoSuite evosuite = new EvoSuite();
    String targetClass = SingletonUser.class.getCanonicalName();
    Properties.TARGET_CLASS = targetClass;
    Properties.OUTPUT_VARIABLES = "" + RuntimeVariable.HadUnstableTests;
    String[] command = new String[] { "-generateSuite", "-class", targetClass };
    Object result = evosuite.parseCommandLine(command);
    GeneticAlgorithm<?> ga = getGAFromResult(result);
    TestSuiteChromosome best = (TestSuiteChromosome) ga.getBestIndividual();
    System.out.println("EvolvedTestSuite:\n" + best);
    Map<String, OutputVariable<?>> map = DebugStatisticsBackend.getLatestWritten();
    Assert.assertNotNull(map);
    OutputVariable unstable = map.get(RuntimeVariable.HadUnstableTests.toString());
    Assert.assertNotNull(unstable);
    Assert.assertEquals(Boolean.FALSE, unstable.getValue());
}
Also used : EvoSuite(org.evosuite.EvoSuite) TestSuiteChromosome(org.evosuite.testsuite.TestSuiteChromosome) OutputVariable(org.evosuite.statistics.OutputVariable) Test(org.junit.Test)

Example 13 with OutputVariable

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

the class TypeErasureSystemTest method testTypeErasure.

@Test
public void testTypeErasure() {
    EvoSuite evosuite = new EvoSuite();
    String targetClass = TypeErasure.class.getCanonicalName();
    Properties.TARGET_CLASS = targetClass;
    Properties.OUTPUT_VARIABLES = "" + RuntimeVariable.HadUnstableTests;
    String[] command = new String[] { "-generateSuite", "-class", targetClass };
    Object result = evosuite.parseCommandLine(command);
    GeneticAlgorithm<?> ga = getGAFromResult(result);
    TestSuiteChromosome best = (TestSuiteChromosome) ga.getBestIndividual();
    System.out.println("EvolvedTestSuite:\n" + best);
    Map<String, OutputVariable<?>> map = DebugStatisticsBackend.getLatestWritten();
    Assert.assertNotNull(map);
    OutputVariable unstable = map.get(RuntimeVariable.HadUnstableTests.toString());
    Assert.assertNotNull(unstable);
    Assert.assertEquals(Boolean.FALSE, unstable.getValue());
}
Also used : EvoSuite(org.evosuite.EvoSuite) TestSuiteChromosome(org.evosuite.testsuite.TestSuiteChromosome) OutputVariable(org.evosuite.statistics.OutputVariable) Test(org.junit.Test)

Example 14 with OutputVariable

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

the class RandomUserSystemTest method testRandom.

@Test
public void testRandom() {
    EvoSuite evosuite = new EvoSuite();
    String targetClass = RandomUser.class.getCanonicalName();
    Properties.TARGET_CLASS = targetClass;
    Properties.OUTPUT_VARIABLES = "" + RuntimeVariable.HadUnstableTests;
    String[] command = new String[] { "-generateSuite", "-class", targetClass };
    Object result = evosuite.parseCommandLine(command);
    GeneticAlgorithm<?> ga = getGAFromResult(result);
    TestSuiteChromosome best = (TestSuiteChromosome) ga.getBestIndividual();
    System.out.println("EvolvedTestSuite:\n" + best);
    CheapPurityAnalyzer purityAnalyzer = CheapPurityAnalyzer.getInstance();
    String descriptor = Type.getMethodDescriptor(Type.INT_TYPE);
    boolean nextInt = purityAnalyzer.isPure(targetClass, "nextInt", descriptor);
    assertFalse(nextInt);
    boolean randomNextInt = purityAnalyzer.isPure(java.util.Random.class.getCanonicalName(), "nextInt", descriptor);
    assertFalse(randomNextInt);
    boolean secureRandomNextInt = purityAnalyzer.isPure(java.security.SecureRandom.class.getCanonicalName(), "nextInt", descriptor);
    assertFalse(secureRandomNextInt);
    Map<String, OutputVariable<?>> map = DebugStatisticsBackend.getLatestWritten();
    Assert.assertNotNull(map);
    OutputVariable unstable = map.get(RuntimeVariable.HadUnstableTests.toString());
    Assert.assertNotNull(unstable);
    Assert.assertEquals(Boolean.FALSE, unstable.getValue());
}
Also used : OutputVariable(org.evosuite.statistics.OutputVariable) CheapPurityAnalyzer(org.evosuite.assertion.CheapPurityAnalyzer) EvoSuite(org.evosuite.EvoSuite) TestSuiteChromosome(org.evosuite.testsuite.TestSuiteChromosome) Test(org.junit.Test)

Example 15 with OutputVariable

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

the class ResourceLoaderUserSystemTest method testResourceLoader.

@Test
public void testResourceLoader() {
    EvoSuite evosuite = new EvoSuite();
    String targetClass = ResourceLoaderUser.class.getCanonicalName();
    Properties.TARGET_CLASS = targetClass;
    Properties.OUTPUT_VARIABLES = "" + RuntimeVariable.HadUnstableTests;
    String[] command = new String[] { "-generateSuite", "-class", targetClass };
    Object result = evosuite.parseCommandLine(command);
    GeneticAlgorithm<?> ga = getGAFromResult(result);
    TestSuiteChromosome best = (TestSuiteChromosome) ga.getBestIndividual();
    System.out.println("EvolvedTestSuite:\n" + best);
    Map<String, OutputVariable<?>> map = DebugStatisticsBackend.getLatestWritten();
    Assert.assertNotNull(map);
    OutputVariable unstable = map.get(RuntimeVariable.HadUnstableTests.toString());
    Assert.assertNotNull(unstable);
    Assert.assertEquals(Boolean.FALSE, unstable.getValue());
}
Also used : EvoSuite(org.evosuite.EvoSuite) TestSuiteChromosome(org.evosuite.testsuite.TestSuiteChromosome) OutputVariable(org.evosuite.statistics.OutputVariable) Test(org.junit.Test)

Aggregations

OutputVariable (org.evosuite.statistics.OutputVariable)71 Test (org.junit.Test)67 EvoSuite (org.evosuite.EvoSuite)61 TestSuiteChromosome (org.evosuite.testsuite.TestSuiteChromosome)49 SearchStatistics (org.evosuite.statistics.SearchStatistics)19 Properties (org.evosuite.Properties)18 CheapPurityAnalyzer (org.evosuite.assertion.CheapPurityAnalyzer)13 CalculatorTest (com.examples.with.different.packagename.CalculatorTest)2 Ignore (org.junit.Ignore)2 ClassHierarchyIncludingInterfacesTest (com.examples.with.different.packagename.ClassHierarchyIncludingInterfacesTest)1 ClassNumberUtilsTest (com.examples.with.different.packagename.ClassNumberUtilsTest)1 ClassPublicInterfaceTest (com.examples.with.different.packagename.ClassPublicInterfaceTest)1 ClassWithPrivateInterfacesTest (com.examples.with.different.packagename.ClassWithPrivateInterfacesTest)1 FinalClassTest (com.examples.with.different.packagename.FinalClassTest)1 StringUtilsEqualsIndexOfTest (com.examples.with.different.packagename.StringUtilsEqualsIndexOfTest)1 WordUtilsTest (com.examples.with.different.packagename.WordUtilsTest)1 AbstractInspector (com.examples.with.different.packagename.purity.AbstractInspector)1 AbstractToStringInspector (com.examples.with.different.packagename.purity.AbstractToStringInspector)1