Summer Sale! All accounts are 50% off this week.

BernardoBF4's avatar

Documenting tests on the code it covers

I am seraching for an extension for VS Code that warns me when a feature covered by a test doesn't exist anymore, but still haven't found anything yet. I explain better below.

Let's say I have feature A, which is covered by a test, and I just coded feature B, also covered by a test I am about to run. If the code for feature B didn't break anything, the test for feature A will pass; but if it broke anything, feature A's test won't pass. But, there is, at least, one case when the test might not pass, but not because of feature B's code: it might be because feature A simply doesn't need to exist anymore, and was removed, but someone forgot to remove the tests that covered it.

I know that when removing a feature, someone should run the tests and remove the ones that covered the feature, because those test cover nothing anymore. But just in case the developer forgot to remove the tests, it would be so nice if one could just hover on the function/class/if and see a list of existing tests that cover that part of the code, to know what to remove. Also, if the tests where properly named, one could also hover on the function/class/if and get to know why that part of the code is there anyways.

Well, if anyone knows of some extension that does that, I'd be pleased to know it. Thanks a lot.

0 likes
1 reply
automica's avatar

relying on a test name matching method its testing's name is pretty unrealistic. If you are testing an api route for example, it would be difficult to static analyse code to see what the test is hitting.

Feels like a step in your git push command to run test suites would be a best match here.

Please or to participate in this conversation.