/** * Execute a test case on a new scope * * @param tc * a {@link org.evosuite.testcase.TestCase} object. * @return a {@link org.evosuite.testcase.execution.ExecutionResult} object. */ public ExecutionResult execute(TestCase tc) { ExecutionResult result = execute(tc, Properties.TIMEOUT); return result; }
/** * <p> * runTest * </p> * * @param test a {@link org.evosuite.testcase.TestCase} object. * @return a {@link org.evosuite.testcase.execution.ExecutionResult} object. */ protected ExecutionResult runTest(TestCase test) { ExecutionResult result = new ExecutionResult(test, null); try { logger.debug("Executing test"); result = executor.execute(test); } catch (Exception e) { throw new Error(e); } return result; }
/** * <p>runTest</p> * * @param test a {@link org.evosuite.testcase.TestCase} object. * @return a {@link org.evosuite.testcase.execution.ExecutionResult} object. */ public ExecutionResult runTest(TestCase test) { ExecutionResult result = new ExecutionResult(test, null); try { logger.debug("Executing test"); result = executor.execute(test); int num = test.size(); MaxStatementsStoppingCondition.statementsExecuted(num); //result.touched.addAll(HOMObserver.getTouched()); } catch (Exception e) { throw new Error(e); } return result; }
/** * Execute a test case on a new scope * * @param tc * a {@link org.evosuite.testcase.TestCase} object. * @return a {@link org.evosuite.testcase.execution.ExecutionResult} object. */ public ExecutionResult execute(TestCase tc, int timeout) { Scope scope = new Scope(); ExecutionResult result = execute(tc, scope, timeout); if (Properties.RESET_STATIC_FIELDS) { logger.debug("Resetting classes after execution"); ClassReInitializer.getInstance().reInitializeClassesAfterTestExecution(tc, result); } return result; }
/** * Execute a test case * * @param test * The test case to execute * @return Result of the execution */ public static ExecutionResult runTest(TestCase test) { ExecutionResult result = new ExecutionResult(test, null); try { TestCaseExecutor executor = getInstance(); logger.debug("Executing test"); result = executor.execute(test); MaxStatementsStoppingCondition.statementsExecuted(result.getExecutedStatements()); } catch (Exception e) { logger.error("TG: Exception caught: ", e); throw new Error(e); } return result; }
/** * Execute a test case * * @param test * The test case to execute * @return Result of the execution */ @Deprecated public ExecutionResult runTest(TestCase test) { ExecutionResult result = new ExecutionResult(test, null); try { result = TestCaseExecutor.getInstance().execute(test); MaxStatementsStoppingCondition.statementsExecuted(result.getExecutedStatements()); } catch (Exception e) { logger.warn("TG: Exception caught: " + e.getMessage(), e); try { Thread.sleep(1000); result.setTrace(ExecutionTracer.getExecutionTracer().getTrace()); } catch (Exception e1) { throw new Error(e1); } } // System.out.println("TG: Killed "+result.getNumKilled()+" out of "+mutants.size()); return result; }
private void initializeTargetClass() throws Throwable { String cp = ClassPathHandler.getInstance().getTargetProjectClasspath(); // Here is where the <clinit> code should be invoked for the first time DefaultTestCase test = buildLoadTargetClassTestCase(Properties.TARGET_CLASS); ExecutionResult execResult = TestCaseExecutor.getInstance().execute(test, Integer.MAX_VALUE); if (hasThrownInitializerError(execResult)) { // create single test suite with Class.forName() writeJUnitTestSuiteForFailedInitialization(); ExceptionInInitializerError ex = getInitializerError(execResult); throw ex; } else if (!execResult.getAllThrownExceptions().isEmpty()) { // some other exception has been thrown during initialization Throwable t = execResult.getAllThrownExceptions().iterator().next(); throw t; } DependencyAnalysis.analyzeClass(Properties.TARGET_CLASS, Arrays.asList(cp.split(File.pathSeparator))); LoggingUtils.getEvoLogger().info("* " + ClientProcess.getPrettyPrintIdentifier() + "Finished analyzing classpath"); }
@SuppressWarnings({ "rawtypes", "unchecked", "unused" }) private void createConcretePrimitives(TestCase test) { // Execute test to collect concrete values TestCaseExecutor executor = TestCaseExecutor.getInstance(); ConcreteValueObserver observer = new ConcreteValueObserver(); executor.addObserver(observer); executor.execute(test); executor.removeObserver(observer); // Now replace references to concrete values with new primitive statements Map<Integer, Object> concreteValues = observer.getConcreteValues(); List<Integer> positions = new ArrayList<Integer>(concreteValues.keySet()); Collections.sort(positions, Collections.reverseOrder()); for (Integer position : positions) { Object value = concreteValues.get(position); Statement statement = test.getStatement(position); PrimitiveStatement primitive = PrimitiveStatement.getPrimitiveStatement(test, new GenericClass( value.getClass())); primitive.setValue(value); VariableReference replacement = test.addStatement(primitive, position); test.replace(statement.getReturnValue(), replacement); } }
/** * Execute a test case * * @param test * The test case to execute * @return Result of the execution */ protected ExecutionResult runTest(TestChromosome test) { if (!test.isChanged() && test.getLastExecutionResult() != null) return test.getLastExecutionResult(); try { ExecutionResult result = TestCaseExecutor.getInstance().execute(test.getTestCase()); return result; } catch (Exception e) { logger.error("TG: Exception caught: ", e); throw new EvosuiteError(e); } } }
/** * <p> * inline * </p> * * @param test * a {@link org.evosuite.testcase.TestCase} object. */ public void inline(TestCase test) { this.test = test; TestCaseExecutor executor = TestCaseExecutor.getInstance(); executor.addObserver(this); executor.execute(test); executor.removeObserver(this); removeUnusedVariables(test); assert (test.isValid()); }
result = TestCaseExecutor.getInstance().execute(test); if (mutant != null) MutationObserver.deactivateMutation(mutant);
/** {@inheritDoc} */ public static ExecutionResult runTest(TestCase test, Mutation mutant) { ExecutionResult result = new ExecutionResult(test, mutant); try { if (mutant != null) logger.debug("Executing test for mutant " + mutant.getId() + ": \n" + test.toCode()); else logger.debug("Executing test without mutant"); if (mutant != null) MutationObserver.activateMutation(mutant); result = TestCaseExecutor.getInstance().execute(test); if (mutant != null) MutationObserver.deactivateMutation(mutant); int num = test.size(); if (!result.noThrownExceptions()) { num = result.getFirstPositionOfThrownException(); } //if (mutant == null) MaxStatementsStoppingCondition.statementsExecuted(num); int i = 0; for (AssertionTraceObserver<?> observer : observers) { result.setTrace(observer.getTrace(), observerClasses[i++]); } } catch (Exception e) { throw new Error(e); } return result; }
/** * Execute a test case * * @param testChromosome The test case to execute * @return Result of the execution */ public ExecutionResult runTest(TestChromosome testChromosome) { if (testChromosome.getLastExecutionResult() != null && !testChromosome.isChanged()) { return testChromosome.getLastExecutionResult(); } TestCase test = testChromosome.getTestCase(); ExecutionResult result = new ExecutionResult(test, null); try { result = TestCaseExecutor.getInstance().execute(test); int num = test.size(); if (!result.noThrownExceptions()) { num = result.getFirstPositionOfThrownException(); } MaxStatementsStoppingCondition.statementsExecuted(num); // for(TestObserver observer : observers) { // observer.testResult(result); // } } catch (Exception e) { logger.error("TG: Exception caught: ", e); throw new RuntimeException(e); } return result; }
result = TestCaseExecutor.getInstance().execute(defaultTestCase, Properties.CONCOLIC_TIMEOUT);
@Test public void checksClassIsLoadedUsingInstrumentingClassLoader() throws ClassNotFoundException { Properties.CLIENT_ON_THREAD = true; final String className = SimpleClass.class.getCanonicalName(); TestCaseExecutor.initExecutor(); TestGenerationContext.getInstance().resetContext(); ClassPathHandler.getInstance().changeTargetCPtoTheSameAsEvoSuite(); InstrumentingClassLoader classLoader = TestGenerationContext.getInstance().getClassLoaderForSUT(); assertFalse(classLoader.getLoadedClasses().contains(className)); DefaultTestCase test = buildLoadTargetClassTestCase(className); TestCaseExecutor.getInstance().execute(test, Integer.MAX_VALUE); assertTrue(classLoader.getLoadedClasses().contains(className)); }
logger.debug("Executing test"); result = TestCaseExecutor.getInstance().execute(test);
/** * Execute a test case on the original unit * * @param test * The test case that should be executed * @return a {@link org.evosuite.testcase.execution.ExecutionResult} object. */ protected ExecutionResult runTest(TestCase test) { ExecutionResult result = new ExecutionResult(test); try { logger.debug("Executing test"); result = TestCaseExecutor.getInstance().execute(test); int num = test.size(); MaxStatementsStoppingCondition.statementsExecuted(num); result.setTrace(comparisonObserver.getTrace(), ComparisonTraceEntry.class); result.setTrace(primitiveObserver.getTrace(), PrimitiveTraceEntry.class); result.setTrace(inspectorObserver.getTrace(), InspectorTraceEntry.class); result.setTrace(fieldObserver.getTrace(), PrimitiveFieldTraceEntry.class); result.setTrace(nullObserver.getTrace(), NullTraceEntry.class); result.setTrace(sameObserver.getTrace(), SameTraceEntry.class); if(!Properties.isRegression()) result.setTrace(arrayObserver.getTrace(), ArrayTraceEntry.class); result.setTrace(arrayLengthObserver.getTrace(), ArrayLengthTraceEntry.class); result.setTrace(containsTraceObserver.getTrace(), ContainsTraceEntry.class); } catch (Exception e) { throw new Error(e); } return result; }
@Test public void testShowInputDialogWasFound() throws Exception { boolean hasStringDialog0 = JOptionPaneInputs.getInstance().hasDialog(GUIAction.STRING_INPUT); assertFalse(hasStringDialog0); InstrumentingClassLoader cl = new InstrumentingClassLoader(); TestCase t1 = buildTestCase0(cl); TestCaseExecutor.getInstance().execute(t1); boolean hasStringDialog = JOptionPaneInputs.getInstance().hasDialog(GUIAction.STRING_INPUT); assertTrue(hasStringDialog); }
MutationObserver.activateMutation(mutant); result = TestCaseExecutor.getInstance().execute(test); MutationObserver.deactivateMutation(mutant);