public void filterFailingAssertions(List<TestCase> testCases) { List<TestCase> tests = new ArrayList<TestCase>(); tests.addAll(testCases); for(TestCase test : tests) { filterFailingAssertions(test); } // Execute again in different order Randomness.shuffle(tests); for(TestCase test : tests) { filterFailingAssertions(test); } }
/** * Add assertions to all tests in a test suite * * @param suite */ public void addAssertions(TestSuiteChromosome suite) { setupClassLoader(suite); for(TestChromosome test : suite.getTestChromosomes()) { if(!TimeController.getInstance().hasTimeToExecuteATestCase()) break; addAssertions(test.getTestCase()); } }
public static void addAssertions(TestSuiteChromosome tests) { AssertionGenerator asserter; ContractChecker.setActive(false); if (Properties.ASSERTION_STRATEGY == AssertionStrategy.MUTATION) { asserter = new SimpleMutationAssertionGenerator(); } else if (Properties.ASSERTION_STRATEGY == AssertionStrategy.ALL) { asserter = new CompleteAssertionGenerator(); } else asserter = new UnitAssertionGenerator(); asserter.addAssertions(tests); if (Properties.FILTER_ASSERTIONS) asserter.filterFailingAssertions(tests); } }
/** * Reinstrument to make sure final fields are removed * * @param suite */ public void setupClassLoader(TestSuiteChromosome suite) { if (!Properties.RESET_STATIC_FIELDS) { return; } final boolean reset_all_classes = Properties.RESET_ALL_CLASSES_DURING_ASSERTION_GENERATION; ClassReInitializer.getInstance().setReInitializeAllClasses(reset_all_classes); changeClassLoader(suite); }
protected void filterFailingAssertions(TestCase test) { // Make sure we are not keeping assertions influenced by static state // TODO: Need to handle statically initialized classes ExecutionResult result = runTest(test); Set<Assertion> invalidAssertions = new HashSet<Assertion>(); for(Assertion assertion : test.getAssertions()) { for(OutputTrace<?> outputTrace : result.getTraces()) { if(outputTrace.isDetectedBy(assertion)) { invalidAssertions.add(assertion); break; } } } logger.info("Removing {} nondeterministic assertions", invalidAssertions.size()); for(Assertion assertion : invalidAssertions) { test.removeAssertion(assertion); } }
public void filterFailingAssertions(TestSuiteChromosome testSuite) { List<TestChromosome> tests = testSuite.getTestChromosomes(); for(TestChromosome test : tests) { filterFailingAssertions(test.getTestCase()); } // Execute again in different order Randomness.shuffle(tests); for(TestChromosome test : tests) { filterFailingAssertions(test.getTestCase()); } }