Best Approach for testing VB DLL's during Design Time?

Posted on 2003-03-19
Medium Priority
Last Modified: 2010-04-07
Perhaps I'm just missing something all together here. I'm developing a DLL in Visual Basic 6 to drive a data-driven website.  As I develop the various classes of the model, I like to unit test each piece to be sure it functions as expected. The way I understand it, I have two options:

1. Build a VBForm based test app that references the compiled DLL, and write code against it to perform tests. When tests fail, go back to the DLL code, make changes, compile, and then go back to the test app. Problem here is I can't step into code and debug.

2. Build a VBForm based test app that includes each of the classes, so that I can test, step through code, make changes etc. until it works as desired.

Approach 2 works well enough I guess, except I have to have a seperate "tester" project setup, and I have to add to it all the classes I'm developing within my DLL project, and loading them into the tester EXE project changes their instancing properties, which I then have to change back when I open the DLL project back up etc..

Any thoughts? What's the best approach to being able to run and debug code in a DLL project as I work?

Question by:PMH4514
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
  • 5
  • 3
LVL 38

Expert Comment

ID: 8166604
You can debug your DLL in the IDE.  You can either add your client project to the project group and run them together, or you can run the DLL in one instance of VB and run a client in another instance.  If you have referenced the project in the client and the DLL is running when you run the client, you will hook into the instance of the DLL running in the IDE.
LVL 38

Accepted Solution

PaulHews earned 400 total points
ID: 8166617
Another option is to add a module to your DLL project and write testing procedures that instantiate the class and call methods.  I use this as a first line of debugging...

Write a method, write a test procedure, call it from the immediate window, check the output.

Author Comment

ID: 8166635
Adding a module to the DLL project sounds like a suitable solution.. Should this module be removed from the DLL for "production" ? - is there an issue with having an ActiveX DLL that contains a module as far as IIS is concerned?

Modern healthcare requires a modern cloud. View this brief video to understand how the Concerto Cloud for Healthcare can help your organization.

LVL 38

Expert Comment

ID: 8166758
No not at all.  The code will never be called, except from the immediate window, and the size it adds will be negligible.  All my production DLLs still have their DebugBas module intact.

Author Comment

ID: 8166795
do I have to setup my debugbas module as the startup or something? i set it up and hit run, I however cannot type anything into the immediate window at that point.
LVL 38

Expert Comment

ID: 8167054
Don't hit run.  Call your function/sub directly from the debug window without starting the project.  
LVL 38

Expert Comment

ID: 8167083

in DebugBas, I have a sub

Public Sub TestMethod_X()
 Dim oMyObj as clsPublicClass
 Dim strReturn as string

 Set oMyObj = New clsPublicClass
 strReturn = oMyObj.X("testdata")
 Debug.Print strReturn
End Sub

Now in the debug window, I just type:


And hit return.  Any breakpoints I set in TestMethod_X or in oMyObj.X will be hit, and I can step through the code.
LVL 11

Expert Comment

ID: 8167092
You can create a project group that will contain both your test app and your DLL. If you call a method of the DLL then you can step into it to debug it manually.

This works for any activeX-DLL. If you create a activeX-EXE then you need to open a 2nd instance of the IDE in order to debug it. (Start the EXE IDE - Then start the test-IDE and create an instance of the object you want to test)

Hope this helps


Author Comment

ID: 8168154
rdrunner's approach is a perfectly workable solution as well I'm finding.. especially if you want to use form elements..

Featured Post

Industry Leaders: We Want Your Opinion!

We value your feedback.

Take our survey and automatically be enter to win anyone of the following:
Yeti Cooler, Amazon eGift Card, and Movie eGift Card!

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Most everyone who has done any programming in VB6 knows that you can do something in code like Debug.Print MyVar and that when the program runs from the IDE, the value of MyVar will be displayed in the Immediate Window. Less well known is Debug.Asse…
Enums (shorthand for ‘enumerations’) are not often used by programmers but they can be quite valuable when they are.  What are they? An Enum is just a type of variable like a string or an Integer, but in this case one that you create that contains…
Get people started with the utilization of class modules. Class modules can be a powerful tool in Microsoft Access. They allow you to create self-contained objects that encapsulate functionality. They can easily hide the complexity of a process from…
Show developers how to use a criteria form to limit the data that appears on an Access report. It is a common requirement that users can specify the criteria for a report at runtime. The easiest way to accomplish this is using a criteria form that a…
Suggested Courses

764 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question