My @After function is:
public void tearDown() throws Exception {
driver.quit();
String verificationErrorString = verificationErrors.toString();
if (!"".equals(verificationErrorString)) {
fail(verificationErrorString);
}
}
and when I run the test I get an error:
java.lang.AddesrtionError: java.langAssertionErrorjava.lang.AssertionError
at tear.Down, line:
fail(verificationErrorString);
How to fix this one?
It appears you are misunderstanding the purpose of Assert.fail(...) which is intended to cause a test to fail with the error message passed as a string. It does this by throwing an AssertionError. This is working as intended, its purpose is not failure logging.
I'm guessing that you want to report or log the verificationErrorString. If this is so then add the following to the top of your TestCase class.
Logger logger = LoggerFactory.getLogger(TestCase.class);
Then replace your fail(verificationErrorString) with some thing like
logger.warning(verificationErrorString);
or
logger.error(verificationErrorString);
However you could (should) just put those directly in the tests.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With