I’ve been going through a VB6 application called SimplyVBUnit. Now the great thing is that the person who wrote this has released its source and I have been attempting to work out how they actually accomplished the unit testing functionality for VB6 but so far I have struggled to understand how the code works.
Basically what I am hoping somebody can explain to me is how one create a unit testing framework for VB6 given (to the best of my knowledge) it doesn’t implement anything similar to the “Compiler Services” or reflection provided by .NET?
Without these features I can’t get my head around how one could invoke a method/object/whatever dynamically at runtime and observe the result. Any chance someone could provide some input?
I’ve been using SimplyVBUnit in an old VB6 app. It’s great. I have over 100 tests. But I had to heavily change it to integrate it with my app (e.g. so that I can go to the Help menu and run Unit Tests. Specifically, I separated the UI from the actual implementation, so it’s UI agnostic.
The source is actually not that complicated (once you grok what the guy is doing). VB6 does not have any reflection and TLBINF32.DLL only works on external DLLs, thus if you wanted to integrate SimplyVBUnit into your app, you can’t take that approach.
You create a Unit Test class in an ActiveX DLL that inherits from ITestCase. You implement a method called RunTest. Inside the method, you have the following:
You then pass your class into the UnitTest framework and it calls the RunTest method on it.
I can share the code if you wish to disconnect the UI from the implementation.