Capture Input Example

Your business logic tests can greatly improve maintainability of your documentation. The example below tests what account types are allowed to perform Trading Activities. Test is using WebTau testing framework to define and capture test data. As part of validation of account types, the test also captures data that was used for testing. We can refer to this data later in our documentation by using the include-table plugin Your test data and user-facing documentation is now linked. Account Type Operation Restriction SPB3 Buy Options weekends only TR Sell Futures except holidays BOSS Buy Stocks none package org.testingisdocumenting.testing.examples import org.junit.Test import org.testingisdocumenting.webtau.data.table.TableData import static org.testingisdocumenting.webtau.WebTauCore.* class TestToDocExample { @Test void shouldRestrictAccountsActivity() { def rules = ["Account Type" | "Operation" | "Restriction"] { _________________________________________________ "SPB3" | "Buy Options" | "weekends only" "TR" | "Sell Futures" | "except holidays" "BOSS" | "Buy Stocks" | "none" } validateRules(rules) } private static void validateRules(TableData rules) { doc.capture("account-rules", rules) // capture table data as JSON } } :include-table: account-rules.json