I was reading about the js-test-driver unit-testing framework, when I found out that the guys behind the framework intend it to be integrated with an assertion framework. What is an assertion framework? Is it a kind of unit-testing framework? If it is the case what is specific to such frameworks?
- Anybody can ask a question
- Anybody can answer
- The best answers are voted up and rise to the top
An example of an Assertion Framework would be Hamcrest which was integrated into JUnit 4. Hamcrest does not run tests, it merely provides an expressive way to write assertions.
Old JUnit style equality assertion:
Hamcrest style equality assertions:
Essentially, an assertion framework allows you to perform your assertions in an easily extensible manner. Because the assertion framework focuses on assertions alone, it can do the job much better than a tool that has to collect and run tests as well. NUnit has also adopted the Hamcrest approach to assertions. You would not use Hamcrest to run your tests, merely to write the assertions.
JsTestDriver is primarily concerned with providing a test-runner, i.e. the way that you execute the tests.
It provides a built in assertion framework, which is xUnit in style. This is used to actually write the tests (e.g. assertTrue, assertEquals, etc). However, it also allows you to plugin in alternative assertion frameworks. There are currently plugins available for Unit and Jasmine, which offers BDD style assertions.