Tips On Using Vb Unit

Some tips on using VbUnitThree, most of which also apply to earlier versions.


On the Yahoo Refactoring mailing list TobinHarris asked some questions about how to use vbUnit3 (VbUnitThree) effectively. My response grew somewhat detailed, so I posted it here:

I used Bodo's vbUnit2 on my previous project and am now using vbUnit3 (both professional and basic) on my current project (in late 2001). (...and another project in 2002.)

I find it best to have my application code in an ActiveX server, typically a DLL, in one directory, and the test code in another directory. That way I can easily compile the production code and not accidently get test code mixed in. Use "Project -> References" to make the test project "point to" the application project. Create a group file in the test directory that includes both the test project(s) and production project(s); that way you can debug and step through both.

I often have the vbUnit test project as a subdirectory of the application project it tests. Typical organization:

-- JeffGrigg


Limitations:


MockObjectsInVb describes a technique widely use in other languages, that is very relevant to VbUnit.


[Inspired by some comments on VbUnitWishList, and some conversation I had with BodoMaass]

You need to do some comparisons and assertions that vbUnit does not support: Comparing objects, comparing file contents, comparing binary strings, comparint Variant variables to ensure that both type and value are equal, or any of many other kinds of comparisons you may wish to do.

Should you try to put the new comparison into vbUnit, or should you write a function in your testing application to do the comparison?

Answer: Write functions and methods in your test project(s). If they prove useful, you'll want to put them in a common file or project, for use across your test projects. If they prove very useful, and seem to be something that people on different projects may find useful, then you might offer them to BodoMaass for inclusion in vbUnit.

Realize that even if BodoMaass does not wish to include your valuable reusable functions in the official release of vbUnit, you could always package your library of reusable functions and publish them independently, for people to use with vbUnit. So don't be discouraged; there's always a way.

Here's an arbitrary data point: On a moderately sized test project I happen to be looking at right now, I have a module ("modDebugReuse") with 243 lines of functions that are used by multiple test fixtures. In this project I have one test suite, 15 test fixtures, 8 mock objects, and 9 additional classes that help support testing - several of which are fairly well reused. -- JeffGrigg

While I may not have time to include and support every addition to vbUnit in the main distribution, I'll be happy to post any add-on on the vbUnit website. -- BodoMaass

Hint Taken. Seriously, that sounds a much better idea than adding too much to VBUnit. -- AndyMorris


Sometimes it's a bit of a fag creating suites that only run one fixture, or your suite takes a while to run and you only want to run one fixture, PutSmallFixtureInWithSuite -- AndyMorris


CategoryTesting


EditText of this page (last edited February 23, 2005) or FindPage with title or text search