mirror of
https://github.com/catchorg/Catch2.git
synced 2024-11-29 16:53:30 +01:00
Expanded test-cases-and-exceptions docs and added to reference-index
This commit is contained in:
parent
4ab680a4fb
commit
76ef79a990
@ -4,6 +4,7 @@ Before looking at this material be sure to read the [tutorial](tutorial.md)
|
|||||||
|
|
||||||
* [Command Line](command-line.md)
|
* [Command Line](command-line.md)
|
||||||
* [Assertion Macros](assertions.md)
|
* [Assertion Macros](assertions.md)
|
||||||
|
* [Test cases and sections](test-cases-and-sections.md)
|
||||||
* [Logging Macros](logging.md)
|
* [Logging Macros](logging.md)
|
||||||
* [Supplying your own main()](own-main.md)
|
* [Supplying your own main()](own-main.md)
|
||||||
* [Test fixtures](test-fixtures.md)
|
* [Test fixtures](test-fixtures.md)
|
||||||
|
@ -19,11 +19,26 @@ For examples see the [Tutorial](tutorial.md)
|
|||||||
|
|
||||||
## User Story/ BDD-style test cases
|
## User Story/ BDD-style test cases
|
||||||
|
|
||||||
In addition to Catch's take on the classic style of test cases, Catch supports an alternative syntax that allow tests to be written as "executable specifications" (one of the early goals of BDD). This set of macros map on to TEST_CASEs and SECTIONs, with a little internal support to make them smoother to work with.
|
In addition to Catch's take on the classic style of test cases, Catch supports an alternative syntax that allow tests to be written as "executable specifications" (one of the early goals of [BDD](http://dannorth.net/introducing-bdd/)). This set of macros map on to ```TEST_CASE```s and ```SECTION```s, with a little internal support to make them smoother to work with.
|
||||||
|
|
||||||
**SCENARIO(** _scenario name_ )
|
**SCENARIO(** _scenario name_ [**,** _tags_ ] **)**
|
||||||
|
|
||||||
-{placeholder for given-when-then docs}-
|
This macro maps onto ```TEST_CASE``` and works in the same way, except that the test case name will be prefixed by "Scenario: "
|
||||||
|
|
||||||
|
**GIVEN(** _something_ **)**
|
||||||
|
**WHEN(** _something_ **)**
|
||||||
|
**THEN(** _something_ **)**
|
||||||
|
|
||||||
|
These macros map onto ```SECTION```s except that the section names are the _something_s prefixed by "given: ", "when: " or "then: " respectively.
|
||||||
|
|
||||||
|
**AND_WHEN(** _something_ **)**
|
||||||
|
**AND_THEN(** _something_ **)**
|
||||||
|
|
||||||
|
Similar to ```WHEN``` and ```THEN``` except that the prefixes start with "and ". These are used to chain ```WHEN```s and ```THEN```s together.
|
||||||
|
|
||||||
|
When any of these macros are used the console reporter recognises them and formats the test case header such that the Givens, Whens and Thens are aligned to aid readability.
|
||||||
|
|
||||||
|
Other than the additional prefixes and the formatting in the console reporter these macros behave exactly as ```TEST_CASE```s and ```SECTION```s. As such there is nothing enforcing the correct sequencing of these macros - that's up to the programmer!
|
||||||
|
|
||||||
---
|
---
|
||||||
|
|
||||||
|
Loading…
Reference in New Issue
Block a user