3 ms·
I've been wanting a documentation system that lets me "cite" tests in support of a claim, such that when a test fails the programmer can see what claims that te
by dllthomas 4y ago
I've been wanting a documentation system that lets me "cite" tests in support of a claim, such that when a test fails the programmer can see what claims that test was meant to support, which is crucial context in deciding how to fix the code, test, and/or docs.
- brabel 4y agoYou just need a testing framework that supports specifying context. I write my JVM tests mostly using Spock[1] as it's absolutely great at letting me specify, and ecouraging me to do so, as much context as I can. It may look something like this (this example is loosely based on Spock using Geb[2]): @Narrative(''' Users can choose to authenticate using method A or B. This test makes sure that users can choose one or the other, go back and change their decision later, and complete the procedure with either method. ''') class AuthenticationMethodsSpec extends Specification { def 'Users can choose method A'() { given: 'the user goes to the login page' goTo(LoginPage) when: 'the user chooses method A' page.click('methodA') then: 'the user goes to the method A login page' at LoginMethodA } Error messages are great too... and the tests, at least when written as above, with actual contextual information everywhere necessary, are much better than the usual JUnit abominations you're likely to find in Java shops. It may look superficially similar to Cucumber, but it's IMO much better because it's just Groovy code (and I happen to really like Groovy, some people have trouble with it because it's "not exactly like Java"), no custom parsing of text-based stuff and other complex gimmicks. [1] https://spockframework.org/spock/docs/2.1/index.html https://spockframework.org/spock/docs/2.1/index.html [2] https://www.gebish.org/ https://www.gebish.org/