It ain't just reds and greens: Automated Acceptance Testing and quaternary test outcomes
Join the DZone community and get the full member experience.Join For Free
although they seem simple enough on the surface, test outcomes are actually quite complicated beasts. traditional unit tests, and basic tdd tests, have just two states, passing or failing, represented by red and green in the famous "red-green-refactor" dicton. in behaviour driven development (bdd), on the other hand, we have the additional concept of 'pending' tests: tests that have been specified (for example, in a cucumber or jbehave story) but not yet implemented. when we report on test results, we need to be able to distinguish these three states, as a pending test has very different semantics to a failing test. pending means it's not yet done yet, but this may well be as expected, especially towards the start of a sprint. a failing test, on the other hand, needs fixing. now.
most bdd tools, such as cucumber, jbehave, concordion, easyb and so forth, report test results in terms of these three states. however, the complexity doesn't stop here. maintaining web tests, for example, requires ongoing effort, and can perturb the test reporting if not handed with care. for example, if a web page changes during normal development or refactoring work, the tests that use this page may break. although good software engineering practices such as the use of page objects can reduce the risk of this quite a bit, and reduce the work involved in maintaining the tests when it does, it is still something that will happen regularly. and again, the semantics of a test that is broken is quite different to those of a failing test. a broken test needs maintenance work on the test suite. it may also mask an application error, but you will need to investigate to find out. a failing test means that the application is broken, and therefore needs urgent fixing.
thucydides is an open source library that aims to make automated acceptance testing and reporting easier and more informative. it builds on java testing tools such as jbehave, easyb and even junit, and provides strong integration with selenium 2/webdriver for automated web tests.
in an attempt to address this limitation in conventional bdd reporting, thucydides now distinguishes between test failures (triggered by an assertion error) from test errors (triggered by any other exception). thucydides is an open source library that aims to make automated acceptance testing and reporting easier and more informative. it builds on java testing tools such as jbehave, easyb and even junit, and provides strong integration with selenium 2/webdriver for automated web tests.
when you run your automated acceptance tests using thucydides, any error that triggers an assertionerror (or a subclass of assertionerror) will be considered a test failure. anything else (such as the notfoundexception, when an element is not found on the page) is considered to be an error, and therefore indicative of a broken test.
in the future we may extend thucydides further to make this concept more configurable: for example, so that users can provide exceptions that should be considered as either an error or a test failure, or even adding additional outcome states (e.g infrastructure failure, database not setup, etc.).
Published at DZone with permission of John Ferguson Smart, DZone MVB. See the original article here.
Opinions expressed by DZone contributors are their own.