Skip to content

Improve the check_assert system

Compare
Choose a tag to compare
@mdmintz mdmintz released this 19 Jul 06:40
· 7879 commits to master since this release

The check_assert system may have been confusing to SeleniumBase users. It was built to allow a test to make multiple assertions on a page without raising any test failures until all desired check_asserts were called and then self.process_checks() called after that.

The check_asserts include self.check_assert_element() and self.check_assert_text().

Rather than fail a test immediately after the first assertion failure, the test failure is delayed until later when more assertions have been made. The issue arose when SeleniumBase users called the check_assert methods in their tests without calling self.process_checks() afterward. This led to tests that had failed assertions that were never raised at the end of the test, giving the test a Pass instead of a Fail when it should be failing. Now, self.process_checks() will automatically get called in the tearDown() phase at the end of each test if there are any check_assert exceptions that were never raised by a self.process_checks() call from inside the test, assuming that the end of the test is reached without any other exceptions getting raised, such as ones from all the regular assert statements.