Want to protect your cyber security and still get fast solutions? Ask a secure question today.Go Premium

x
?
Solved

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

Posted on 2003-03-19
9
Medium Priority
?
149 Views
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?

thanks
-paul
0
Comment
Question by:PMH4514
  • 5
  • 3
9 Comments
 
LVL 38

Expert Comment

by:PaulHews
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.
0
 
LVL 38

Accepted Solution

by:
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.
0
 

Author Comment

by:PMH4514
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?
0
Technology Partners: 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!

 
LVL 38

Expert Comment

by:PaulHews
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.
0
 

Author Comment

by:PMH4514
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.
0
 
LVL 38

Expert Comment

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

Expert Comment

by:PaulHews
ID: 8167083
example:

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:

TestMethod_X

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

Expert Comment

by:rdrunner
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


0
 

Author Comment

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

Featured Post

Technology Partners: 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

Introduction While answering a recent question about filtering a custom class collection, I realized that this could be accomplished with very little code by using the ScriptControl (SC) library.  This article will introduce you to the SC library a…
When trying to find the cause of a problem in VBA or VB6 it's often valuable to know what procedures were executed prior to the error. You can use the Call Stack for that but it is often inadequate because it may show procedures you aren't intereste…
Get people started with the process of using Access VBA to control Excel using automation, Microsoft Access can control other applications. An example is the ability to programmatically talk to Excel. Using automation, an Access application can laun…
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…

571 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