Hacker Newsnew | past | comments | ask | show | jobs | submitlogin

This is the approach my uTest testing library (https://github.com/com-lihaoyi/utest) takes. I don't think it's unique to functional tests, even unit tests tend towards this pattern. Tests naturally form a tree structure, for multiple reasons:

- You usually have shared initialization nearer the root and the various cases you want to assert at the leaves.

- You want to group related tests logically together, so it's not one huge flat namespace which gets messy

- You want to run groups of tests at the same time, e.g. when testing a related feature

Typically, these different ways of grouping tests all end up with the same grouping, so it makes a lot of sense to have your tests form a tree rather than a flat list of @Test methods or whatever

Naturally you can always emulate this yourself. e.g. Having helper setup methods that call each other and form a hierarchy, or having a tagging discipline that forms a hierarchy to let you call tests that are related, or simply using files as the leaf-level of the larger filesystem tree to organize your tests. All that works, but it is nice to be able to simplify define a tree of tests in a single file and have all that taken care of for you



Guidelines | FAQ | Lists | API | Security | Legal | Apply to YC | Contact

Search: