Search in sources :

Example 1 with SystemTestBase

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

the class BaseDeterminismSystemTest method run.

private static String run(Class<?> target, Runnable initializer) {
    SystemTestBase scaffolding = new SystemTestBase();
    ByteArrayOutputStream byteStream = new ByteArrayOutputStream();
    PrintStream outStream = new PrintStream(byteStream);
    PrintStream latestOut = System.out;
    System.setOut(outStream);
    // @Before
    scaffolding.setDefaultPropertiesForTestCases();
    Properties.CRITERION = new Properties.Criterion[] { Properties.Criterion.LINE, Properties.Criterion.BRANCH, Properties.Criterion.EXCEPTION, Properties.Criterion.WEAKMUTATION, Properties.Criterion.OUTPUT, Properties.Criterion.METHOD, Properties.Criterion.METHODNOEXCEPTION, Properties.Criterion.CBRANCH };
    if (initializer != null) {
        initializer.run();
    }
    boolean defaultPrint = Properties.PRINT_TO_SYSTEM;
    Properties.PRINT_TO_SYSTEM = true;
    try {
        EvoSuite evosuite = new EvoSuite();
        String targetClass = target.getCanonicalName();
        Properties.TARGET_CLASS = targetClass;
        String[] command = new String[] { "-generateSuite", "-class", targetClass };
        evosuite.parseCommandLine(command);
    } finally {
        // @After
        scaffolding.resetStaticVariables();
        System.setOut(latestOut);
        Properties.PRINT_TO_SYSTEM = defaultPrint;
    }
    return filter(byteStream.toString());
}
Also used : PrintStream(java.io.PrintStream) EvoSuite(org.evosuite.EvoSuite) SystemTestBase(org.evosuite.SystemTestBase) ByteArrayOutputStream(java.io.ByteArrayOutputStream) Properties(org.evosuite.Properties)

Aggregations

ByteArrayOutputStream (java.io.ByteArrayOutputStream)1 PrintStream (java.io.PrintStream)1 EvoSuite (org.evosuite.EvoSuite)1 Properties (org.evosuite.Properties)1 SystemTestBase (org.evosuite.SystemTestBase)1