Using source code visualizations as a coverage map for testing

I’m not a big fan of tracing or linking dead text requirements documents back to test cases unless it is absolutely required. This got me thinking what else can be used as a reference map for testing….?

We all could use some sort of map while testing exploratory’ily(?) So doing some searches I randomly stumbled across this post by Fred Beringer and it struck me that source code visualization can really be useful in exploratory testing. The main problem while exploratory testing is that we could miss critical areas of application. But what if we have such a map?

So if your source code can be visualized into something like this – it might even make exploratory testing or even other testing activities more measurable coverage-wise.

 

There are plenty of source code visualization tools, unfortunately I couldn’t find the one that would work seamlessly for all languages nowadays. Most of the visualizers I came across were language-specific or required a lot of work. But it’ll be worth looking into if you are trying to improve on your test coverage.

There are static code analyzers which can do this job partly, but again there’s a lot of room on how you visualize your code and how you actually use it in testing.

Facebook’s pfff comes pretty close, speaking of universal visualization tool and visualizations aren’t that bad either.

pfff_linux_0.01_c2

There are a few source code visualization libraries on Github which are worth looking into: CodeFlower and DependencyWheel.

While following this approach does have it benefits like aid in exploratory testing, change impact analysis, testing specific-feature or a code-branch (visualization branch not source code control’s branch), and structuring our manual test cases and suites based on code structure.

But, there are also several caveats like initial friction of setting up visualization, dependency of test case structure on code, and not to forget that we’re assuming that test coverage will be governed by visual structure of source tree. Actual visible code-tree might not even be useful at all, visualization might also need to show flow connections from one node to another. That’s when things get complicated. Tracking and visualizing code flow is not impossible but not an easy task either.

 

But even without the flow visualization, a source code map will be a good guidemap for your testing and it’s worth noting that closer your testing will follow the code, less chance of missing things out.

 

About the Author

Abhimanyu is founder of Test Collab, a test case management tool. Test Collab makes your testing more productive and efficient by enabling teams to collaborate in real-time.