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.As system evolves, so do your tests and so does your documentation. Essentially you will have a living document describing aspects of your system.
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
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 WebTau documentation is created using https://github.org/testingisdocumenting/znai Znai. It 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
Use doc.console.capture to capture console output of a provided code block doc.console.capture("http-get-console-output", () -> { http.get("/end-point", ((header, body) -> { DataNode price = body.get("price"); price.should(equal(100)); })); }); https://github.org/testingisdocumenting/znai Znai has cli-output plugin to render ANSI output :include-cli-output: doc-artifacts/http-get-console-output.txt