use of org.evosuite.testcase.execution.TestCaseExecutor in project evosuite by EvoSuite.
the class Contract method fails.
/**
* Run the test against this contract and determine whether it reports a
* failure
*
* @param test
* a {@link org.evosuite.testcase.TestCase} object.
* @return a boolean.
*/
public boolean fails(TestCase test) {
ContractChecker.setActive(false);
TestCaseExecutor executor = TestCaseExecutor.getInstance();
SingleContractChecker checker = new SingleContractChecker(this);
executor.addObserver(checker);
TestCaseExecutor.runTest(test);
executor.removeObserver(checker);
// ContractChecker.setActive(true);
return !checker.isValid();
}
use of org.evosuite.testcase.execution.TestCaseExecutor in project evosuite by EvoSuite.
the class TestCaseExpander method createConcretePrimitives.
@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);
}
}
use of org.evosuite.testcase.execution.TestCaseExecutor in project evosuite by EvoSuite.
the class ConstantInliner method inline.
/**
* <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());
}
Aggregations