Creating a Test Project for an In-Process Component

See Also

This topic describes explains how to set up test projects to exercise most of the objects in-process components can provide. ActiveX documents, however, cannot be tested as described here. See "Building ActiveX Documents."

To create a test project for an in-process component

  1. The test project is loaded in the same copy of the development environment where your component project is loaded. On the File menu, click Add Project to open the Add Project dialog box, click the Standard Exe icon to select it, then click OK to add a Standard Exe project to the project group.

    The caption of the Project window changes to Project Group, with a default name, to indicate that multiple projects are loaded.

    As described in "How to Test ActiveX Components," use an ActiveX Exe project as your test project if your component implements call-backs.

  2. On the File menu, click Save Project Group to save the group containing the component and test project. From now on, you can open both projects simply by opening the project group.

  3. (ActiveX control components skip this step.) Make sure the test project is active — that is, that one of its files is highlighted in the Project window. On the Project menu, click References to open the References dialog box. Locate your component in the list, and check it.

    Note   When setting up a test program for ActiveX control projects, don’t set a reference. A control project automatically adds itself to the Components dialog box the first time you place a control on a test project form. For additional information, see "Debugging Controls" in "Building ActiveX Controls."

    If your component still does not appear in the References dialog box of your test project, make sure at least one class module in the component has its Instancing property set to a value other than Private and PublicNotCreatable.

  4. In the Project window, right-click the test project, and click Set As Start Up on the context menu to make the test project the one that runs when you press F5.

    Note   Because ActiveX control projects cannot be startup projects, a test project added to an ActiveX control project will automatically assume the startup role. If the test project entry in the Project window is in bold-face type, the test project is already the startup project.

  5. Add code to test the properties and methods of each public class provided by your component.

With the test project selected in the Project window, you can use the Object Browser to verify that the public classes, methods, and properties of your component are available. You can also use the Object Browser to examine and add description strings, and to verify that Help topics are correctly linked.

The view you get in the Object Browser differs depending on which project is currently active — that is, which one is selected in the Project window. When your component project is active, the Object Browser will show both public members and Friend functions. When the test project is active, only the public members are visible.

For More Information   Friend functions are discussed in "Private Communications Between Your Objects" in "General Principles of Component Design." Special considerations for debugging ActiveX control projects, including running code at design time, are covered in "Debugging Controls" in "Building ActiveX Controls." ActiveX Documents cannot be debugged without a browser or other active document container. See "Building ActiveX Documents."