/** {@inheritDoc} */ @Override public String getAssertionCode() { String ret_val = ""; for (Assertion a : assertions) { if (a != null) ret_val += a.getCode() + "\n"; } return ret_val; }
/** {@inheritDoc} */ @Override public void addAssertion(Assertion assertion) { if (assertion == null) { logger.warn("Trying to add null assertion!"); } else { logger.debug("Adding assertion " + assertion.getCode()); assert (assertion.isValid()) : "Invalid assertion detected: " + assertion.getCode() + ", " + assertion.getSource() + ", " + assertion.getValue(); assertion.setStatement(this); assertions.add(assertion); } }
/** * Get all assertions based on trace differences * * @param test * a {@link org.evosuite.testcase.TestCase} object. * @param other * a {@link org.evosuite.assertion.OutputTrace} object. * @return a int. */ public int getAssertions(TestCase test, OutputTrace<?> other) { int num = 0; for (Integer statement : trace.keySet()) { if (other.trace.containsKey(statement)) { logger.debug("Other trace contains " + statement); for (Integer var : trace.get(statement).keySet()) { logger.debug("Variable " + var); for (Assertion assertion : trace.get(statement).get(var).getAssertions(other.trace.get(statement).get(var))) { assert (assertion.isValid()) : "Invalid assertion: " + assertion.getCode() + ", " + assertion.value; test.getStatement(statement).addAssertion(assertion); num++; } } } } return num; }
/** * Get all possible assertions * * @param test * a {@link org.evosuite.testcase.TestCase} object. * @return a int. */ public int getAllAssertions(TestCase test, int statement) { int num = 0; if (!trace.containsKey(statement)) return 0; for (Integer var : trace.get(statement).keySet()) { for (Assertion assertion : trace.get(statement).get(var).getAssertions()) { assert (assertion.isValid()) : "Invalid assertion: " + assertion.getCode() + ", " + assertion.value; test.getStatement(statement).addAssertion(assertion); num++; } } return num; }
/** * Get all possible assertions * * @param test * a {@link org.evosuite.testcase.TestCase} object. * @return a int. */ public int getAllAssertions(TestCase test) { int num = 0; for (Integer statement : trace.keySet()) { for (Integer var : trace.get(statement).keySet()) { for (Assertion assertion : trace.get(statement).get(var).getAssertions()) { assert (assertion.isValid()) : "Invalid assertion: " + assertion.getCode() + ", " + assertion.value; if (test.sizeWithAssertions() >= Properties.MAX_LENGTH_TEST_CASE) { return num; } test.getStatement(statement).addAssertion(assertion); num++; } } } return num; }
List<String> assertionComments = new ArrayList<>(); for (Assertion assertion : assertions) { logger.warn("+++++ Assertion: {} {}", assertion.getCode(), assertion.getComment()); assertionComments.add(assertion.getComment());
logger.debug("Adding assertion " + ass.getCode()); if (++numAssertions >= maxAssertions) break; } else { logger.debug("Assertion does not contain target: " + ass.getCode()); logger.debug("Adding assertion " + ass.getCode()); if (++numAssertions >= maxAssertions) break; } else { logger.debug("Assertion does not contain target: " + ass.getCode());