devxlogo

Simple Component Testing

Simple Component Testing

When creating ActiveX components, an easy way to test them is to add a module to the project (see the code below). In this module you can write methods that will instantiate your component and then call the methods.

To make sure nothing was broken, you can keep your unit testing code with the project and call these functions when you have to edit your code.

 Public Sub TestAddition()Dim oAdd As cAddition Set oAdd = New cAddition 'if the result is not 8 then something is not 
working correctlyDebug.Assert oAdd.AddNumbers(5, 3) = 8 Set oAdd = Nothing End Sub

Now all you have to do is type TestAddition in the Immediate window.

devx-admin

Share the Post: