|
|
|
|
|
by krishicks
4086 days ago
|
|
A more advanced version of this can be seen in the some of the tests for CloudFoundry's new Diego runtime: https://github.com/cloudfoundry-incubator/runtime-schema/blo... The 'table' consists of an array of calls to constructors of structs that contain fields which are used to set up the context for each test, set value expectations specific to that test, and whether certain tests in shared examples apply to that context. There is a certain level of cognitive overhead involved in understanding this method of writing tests, to be sure, but the benefits (concise expression of a huge matrix of variations) outweigh the costs (massive duplication, and therefore comprehension of thousands of more lines of test code). It's important to note that this style of test is really best for the situation where there is a large matrix of things you'd like to test. The example I linked included ~70 different contexts, each of which is being run through the large Test() function at the bottom: https://github.com/cloudfoundry-incubator/runtime-schema/blo... |
|