Search in sources :

Example 1 with TestSuiteGenerator

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

the class ClientNodeImpl method startNewSearch.

@Override
public void startNewSearch() throws RemoteException, IllegalStateException {
    if (!state.equals(ClientState.NOT_STARTED)) {
        throw new IllegalArgumentException("Search has already been started");
    }
    /*
		 * Needs to be done on separated thread, otherwise the master will block on this
		 * function call until end of the search, even if it is on remote process
		 */
    searchExecutor.submit(new Runnable() {

        @Override
        public void run() {
            changeState(ClientState.STARTED);
            // Before starting search, let's activate the sandbox
            if (Properties.SANDBOX) {
                Sandbox.initializeSecurityManagerForSUT();
            }
            List<TestGenerationResult> results = new ArrayList<TestGenerationResult>();
            try {
                // Starting a new search
                TestSuiteGenerator generator = new TestSuiteGenerator();
                results.add(generator.generateTestSuite());
                // TODO: Why?
                // GeneticAlgorithm<?> ga = generator.getEmployedGeneticAlgorithm();
                masterNode.evosuite_collectTestGenerationResult(clientRmiIdentifier, results);
            } catch (Throwable t) {
                logger.error("Error when generating tests for: " + Properties.TARGET_CLASS + " with seed " + Randomness.getSeed() + ". Configuration id : " + Properties.CONFIGURATION_ID, t);
                results.add(TestGenerationResultBuilder.buildErrorResult("Error when generating tests for: " + Properties.TARGET_CLASS + ": " + t));
            }
            changeState(ClientState.DONE);
            if (Properties.SANDBOX) {
                /*
					 * Note: this is mainly done for debugging purposes, to simplify how test cases are run/written 
					 */
                Sandbox.resetDefaultSecurityManager();
            }
        /*
				 * System is special due to the handling of properties
				 * 
				 *  TODO: re-add it once we save JUnit code in the 
				 *  best individual. Otherwise, we wouldn't
				 *  be able to properly create the JUnit files in the
				 *  system test cases after the search
				 */
        // org.evosuite.runtime.System.fullReset();
        }
    });
}
Also used : TestGenerationResult(org.evosuite.result.TestGenerationResult) TestSuiteGenerator(org.evosuite.TestSuiteGenerator) ArrayList(java.util.ArrayList) List(java.util.List)

Aggregations

ArrayList (java.util.ArrayList)1 List (java.util.List)1 TestSuiteGenerator (org.evosuite.TestSuiteGenerator)1 TestGenerationResult (org.evosuite.result.TestGenerationResult)1