DEV Community

Cover image for The Power of a Testing Framework
Brad Richardson
Brad Richardson

Posted on • Originally published at everythingfunctional.wordpress.com

The Power of a Testing Framework

I am now ready to call Vegetables a huge success. In my last post I discussed its design and construction. I am now using it in a project at work. The power and convenience it has brought us is huge.

The design of Vegetables is such that its use highly encourages writing your tests in a BDD, or at least a specification style. This means that the act of writing tests encourages you to think more explicitly about the requirements of the code you’re writing.

Now that your test descriptions are written as a requirements specification, the testing framework can report those requirements back to you. We’ve got our tests and our requirements developed as part of a single effort; two birds with one stone.

Next, with all the information collected by the testing framework as part of running the tests, and the ability to ask it be verbose when reporting the results, means our test suite can effectively generate our V&V report for us. That makes 3 things now that we have gotten out of the single effort of developing our test suite.

Finally, I added in the ability to ask the framework to run only a subset of the tests. Add this to the verbose outputs and I can get detailed feedback about the piece of code I’m currently working on, without having to wade through the outputs from the rest of the test suite. This shortens and simplifies the feedback cycle and makes TDD, or at least writing the tests very shortly after the code, much more useful. In fact, I put the following script into our repository for everybody to use while developing or debugging.

#!/bin/bash

DRIVER_PROGRAM="unit_test_build/vegetable_driver"

./shake.sh "${DRIVER_PROGRAM}" && $DRIVER_PROGRAM -q -v -f "${1}"

I think having this level of power and flexibility from my testing framework is going to be a must have for any project of significant size in the future. It has proved to be too useful to do without. And if one like this doesn’t exist in the language I want to use, I’ll now be confident about creating it, since I’ve now done it for Fortran.

Oldest comments (0)