Visual Basic Concepts

Creating the TestThing Test Project

In order to test the ThingDemo component, you need a test project. The test project creates instances of the classes a component provides, and exercises their properties, methods, and events.

To enable debugging of in-process components, Visual Basic allows you to load two or more projects into a project group. In addition to enabling in-process debugging, the project group makes it easier to load your component project and test project.

Note   This topic is part of a series that walks you through creating a sample ActiveX DLL. It begins with the topic Creating an ActiveX DLL.

To add a test project to the project group

  1. On the File menu, click Add Project to open the Add Project dialog box.

    Important   Do not click Open Project or New Project, as these will close your ActiveX DLL project.

  2. Double-click the Standard EXE icon to add an ordinary EXE project. You can now see both projects in the Project Explorer window, and the caption of the Project Explorer window shows the default project group name.

    Notice that ThingDemo appears in bold-face type in the Project Explorer window. This means ThingDemo is the Startup project — that is, the project that will be run when you press F5.

  3. In the Project Explorer window, right-click on Project1 to open the context menu. Click Set as Start Up to make the EXE project the Startup project for the project group.

    Important   The test project must be the Startup project for the group. If the DLL project is the Startup project for the group, the test project will never be run.

  4. On the Project menu, click References to open the References dialog box. Check ThingDemo, then click OK.

    If ThingDemo doesn’t appear in the list of available references, click Cancel to close the dialog box. In the Project Explorer window click Project1 to make it the active project, and then repeat Step 3.

    When working with project groups, make sure you have the right project active before clicking the Project menu.

  5. Press F2 to open the Object Browser. In the Project/Library list, select ThingDemo to show its modules and classes. You can use the Object Browser to examine the Thing object and its properties and methods.

    Click Close to close the Object Browser when you’re done.

  6. On the File menu, click Save Project Group to save the test project and the project group. Name the files as shown below. Name the test project ThingTest. Name the project group ThingDemo. Visual Basic will give the project group file a .vbg extension.

File File name Extension
Form ThingTest_Form1 .frm
Project ThingTest .vbp
Project group ThingDemo .vbg

For More Information   Test projects for DLLs are discussed in more detail in "Creating a Test Project for an In-Process Component" in "Debugging, Testing, and Deploying Components."

Step by Step

This topic is part of a series that walks you through creating a sample ActiveX DLL.

To See
Go to the next step Creating and Testing Thing Objects
Start from the beginning Creating an ActiveX DLL