3 ms·
I write lots of unit tests. One thing I'm struggling with now is the organization of a large number of tests. It's hard to know what I have tests for without go
by abuehrle 12y ago
I write lots of unit tests. One thing I'm struggling with now is the organization of a large number of tests. It's hard to know what I have tests for without going into my tests directory and reading comments. Even then, I feel like I could do more to have a "big picture" overview of my testing strategy rather than seeing a bunch of one-off tests. I haven't quite figured out what that should look like.
I think the IDE could do more in some cases. For example, when unit testing a method, I'd like to be able to tag a reference to the method I'm testing. Then, when I'm in my code, my IDE could show me the docstrings of tests I have for that method.
It's the difference between "hello world" and software design principles used to build large scale systems. I see lots of "hello world" for testing, but not much of the other side. Does anyone have suggestions?
- ereyes01 12y agoThe way I personally solve this problem is by organizing my code and my tests in a similar structure. Split application code up into reasonable files, and split the tests up the same way. Depending on your language/test framework, it also helps to put the test right next to the code... i.e. in Go, you can have component.go and component_test.go in the same directory. I do agree though that it would be nice to see an IDE have some smarts about tests...
- ZeroGravitas 12y agoSome IDEs will read unit test code coverage logs and be able to show you which lines are covered by tests, and which tests exactly cover each line.
- PJDK 12y agoVisual Studio + Resharper lets you do a "Find Usages" of a type or method which is very useful for finding relevant tests. Intellij has the same functionality and I imagine the other JetBrains IDEs are similar. More general advice is that your test structure should mirror your code structure. So a folder called Services should have a matching test folder called Services containing tests for the classes within it.