Browse DevX
Sign up for e-mail newsletters from DevX


Test Drive Test-Driven Development with Visual Basic 6

Test-driven software development lets you utilize the power of automated test suites without having to use a different language. Experience the productivity gains and fun that can be had using this agile development best practice.




Building the Right Environment to Support AI, Machine Learning and Deep Learning

gile development is the new paradigm! (Are you rolling your eyes yet?) Yes, "paradigm" is an overused word but hype aside, agile development does offer some interesting best practices that might turn on its head how you think about developing software. One such practice is test-driven development (TDD), which has gotten a bit of notoriety lately thanks to its association with Extreme Programming.

The basic premise of TDD is to always write an automated test for a piece of functionality first, before you code up the functionality itself. Having an automated test suite ensures that you only ever provide the simplest implementation of the code so that the new test passes. You then write more tests and accordingly alter and extend, or refactor, the application code to get you where you want to be. In this article I will show the rhythm of this approach in development and introduce the one of the available tools for VB6. I'll walk through a simple example, where the focus is on the approach, rather than design or coding problems.

Proponents of this style of development frequently speak about the rhythm of TDD, which consists of:

  1. Write a failing test
  2. Figure 1. Green Bar of Freedom: The vbUnitFree Test Runner gives a green bar to indicate all tests have passed.
  3. Get the test running
  4. Get the test passing
  5. Refactor out any duplication
  6. Rinse and repeat.

The tool that I'll be using is vbUnit, a Visual Basic implementation of the xUnit design. XUnit is the name given to the testing framework design originally created by Kent Beck, the founder of Extreme Programming. JUnit is the most widely used implementation, but it has been ported to more than 30 different languages, so you can safely consider it to be an industry standard. As is customary with xUnit tools, in vbUnit a red bar means that at least one test failed; a green bar means that all tests passed and you can move on to "rhythm" step 4 (see Figure 1).

What You Need
Visual Basic 6
vbUnit3 framework, available free from http://www.vbunit.com
Either the Professional/Evaluation version of the vbUnit3 Test Runner
or the free vbUnitFree Test Runner, available from http://sourceforge.net/projects/vbunitfree/.

Thanks for your registration, follow us on our social networks to keep up-to-date