Living Document

In your test you can capture input and output and save it to a file. By using documentation systems you can use the captured artifacts to render business friendly documentation of your business logic.As system evolves, so do your tests and so does your documentation. Essentially you will have a living document describing your system.

Capture Input

Use doc.capture to save a test captured value to a file. Example below assumes core static import. import static org.testingisdocumenting.webtau.WebTauCore.*; TableData allEmployees = table( "id", "level", "monthsAtCompany", ____________________________________, "alice", 5, 1, "bob", 3, 0, "smith", 4, 1, "cat", 4, 0); addEmployees(allEmployees); doc.capture("all-employees", allEmployees); // capture all employees for documentation purposes

Capture Expected Output

Use doc.expected.capture to save most recent expected value. actual(dao.thisWeekJoiners()).should(equal(table( "*id", "level", "monthsAtCompany", ____________________________________, "bob", 3, 0, "cat", 4, 0))); doc.expected.capture("new-joiners"); // capture expected new joiners for documentation purposes

Znai Example

Since this documentation is rendered using https://github.org/testingisdocumenting/znai Znai here is an example of how to use the captured artifacts. https://github.org/testingisdocumenting/znai Znai has :include-table: plugin to render a table giving a json or CSV file. text :include-table: doc-artifacts/all-employees.json :include-table: doc-artifacts/new-joiners.json Below is the example of the business logic rendered as documentation.Our HR system consider all employees that has been in the company less than a month as new joiners. For example, giving employees: id level monthsAtCompany alice 5 1 bob 3 0 smith 4 1 cat 4 0 System will list following employees as new joiners: id level monthsAtCompany bob 3 0 cat 4 0