Skip to content
Advertisement

Ignore Assertion failure in a testcase (JUnit)

Currently, I am writing the automation testing using java and selenium rc.

I would like to verify all the contents present on the user interface, the function is ie below:

JavaScript

The function is supposed to return a String containing information about the testing. However, the function stopped once an assertion error happened.

Is there a way to ignore the failure and keep executing all the assertion verifications?

Advertisement

Answer

You could use a JUnit 4 error collector rule:

The ErrorCollector rule allows execution of a test to continue after the first problem is found (for example, to collect all the incorrect rows in a table, and report them all at once)

For example you can write a test like this.

JavaScript

The error collector uses hamcrest Matchers. Depending on your preferences this is positive or not.

Advertisement