/** * <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; }
/** {@inheritDoc} */ @Override public ExecutionResult clone() { ExecutionResult copy = new ExecutionResult(test, mutation); copy.exceptions.putAll(exceptions); copy.trace = trace.lazyClone(); copy.explicitExceptions.putAll(explicitExceptions); copy.executionTime = executionTime; copy.regressionObjectDistance = regressionObjectDistance; copy.inputGoals = new LinkedHashMap<>(inputGoals); copy.outputGoals = new LinkedHashMap<>(outputGoals); for (Class<?> clazz : traces.keySet()) { copy.traces.put(clazz, traces.get(clazz).clone()); } if(readProperties!=null){ copy.readProperties = new LinkedHashSet<String>(); copy.readProperties.addAll(readProperties); } copy.wasAnyPropertyWritten = wasAnyPropertyWritten; return copy; }
/** * <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 * * @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; }
/** * Return the number of covered goals * * @param testClass * @param allGoals * @return */ public static Set<TestFitnessFunction> getCoveredGoals(Class<?> testClass, List<TestFitnessFunction> allGoals) { // A dummy Chromosome TestChromosome dummy = new TestChromosome(); dummy.setChanged(false); // Execution result of a dummy Test Case ExecutionResult executionResult = new ExecutionResult(dummy.getTestCase()); Set<TestFitnessFunction> coveredGoals = new HashSet<TestFitnessFunction>(); List<JUnitResult> results = executeTests(testClass); for (JUnitResult testResult : results) { executionResult.setTrace(testResult.getExecutionTrace()); dummy.setLastExecutionResult(executionResult); for(TestFitnessFunction goal : allGoals) { if(coveredGoals.contains(goal)) continue; else if (goal.isCovered(dummy)) coveredGoals.add(goal); } } return coveredGoals; }
ExecutionResult result = new ExecutionResult(test, null);
/** * 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; }
ExecutionResult result = new ExecutionResult(test, mutant);
ExecutionResult executionResult = new ExecutionResult(dummy.getTestCase());
/** {@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; }
ExecutionResult result = new ExecutionResult(defaultTestCase, null);
} catch (ThreadDeath t) { logger.warn("Caught ThreadDeath during test execution"); ExecutionResult result = new ExecutionResult(tc, null); result.setThrownExceptions(callable.getExceptionsThrown()); result.setTrace(ExecutionTracer.getExecutionTracer().getTrace()); ExecutionResult result = new ExecutionResult(tc, null); result.setThrownExceptions(callable.getExceptionsThrown()); result.setTrace(ExecutionTracer.getExecutionTracer().getTrace()); ExecutionResult result = new ExecutionResult(tc, null); result.setThrownExceptions(callable.getExceptionsThrown()); result.setTrace(ExecutionTracer.getExecutionTracer().getTrace()); ExecutionResult result = new ExecutionResult(tc, null); result.setThrownExceptions(callable.getExceptionsThrown()); result.reportNewThrownException(tc.size(), new TestCaseExecutor.TimeoutExceeded());
/** * 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; }
ExecutionResult result = new ExecutionResult(test, mutant);