Your Total Solution for Test Driven Development on the Mainframe
Overview: Test driven development is gaining traction. But as effective and beneficial as it is, it doesn’t work well on the mainframe. Here’s what you can do instead.
While test driven development (TDD) is a popular development approach, wherein you write a test that fails before writing new functional code, it only works when you are writing new code that has few or zero dependencies on other code. It’s more common you’re performing maintenance on existing programs and changes are spread across several areas of the code base.
As on the mainframe, there’s a lot of mainframe software being written, but it’s written into existing complex software programs with many interdependencies. Test driven development doesn’t work for this newly written maintenance code.
Topaz for Total Test, Compuware’s automated testing tool, can help in these maintenance cases by allowing you to generate test cases with test assertions before running the program and verifying it against the assertions. This approach allows test cases to be generated for programs with changed code.
A successful approach for large amounts of existing code is to create a set of unit tests and functional tests for regression testing. Regression tests simply verify code that was working continues to work. They provide a safety net and, when they fail, indicate that your existing code isn’t working as it did before.
In tandem, code coverage indicates how strong this safety net is by letting you know how much code is exercised by the regression tests. The more code that is executed by the test cases, the more likely you are to get a test failure when the code doesn’t behave the same way after you have made changes. A higher percentage of code coverage means a better safety net.
Creating a Safety Net
Creating the safety net of regression tests before making code changes provides you the confidence to make bigger changes and allows you the freedom to clean up code. These code changes can cause the regression tests to fail sometimes—but the failures will be expected. You are making code changes because you have an expected behavior change in the program. The test just needs to be updated to reflect the new behavior of the program.
What you don’t want are unexpected changes. Sometimes failures are unexpected and may be caused by a side effect of the code modifications. Fortunately, the safety net will catch the unexpected behavior and you will know you need to make further updates to correct the problem. Topaz for Total Test can really speed up the creation of unit tests and functional tests ensuring that code changes don’t unexpectedly change the behavior of the code.
So, while you may not always be able to practice test driven development on the mainframe, you can certainly make up for where this methodology is lacking by using Topaz for Total Test to create sets of unit tests and functional tests for regression testing that creates a good safety net.