Writing Test Cases for the CodeDom Test Suite

Copyright (C) Microsoft Corp. 2004. Apache 2.0 License.

Introduction

Test suite users may want to refer to the CodeDom Test Suite Readme document also located in this collection. This document is for those who want to extend the test suite with their own test cases.

The CodeDom test suite allows you to write and build test cases independent of the ones provided with the test suite. These test cases all must derive from the class CodeDomTest (or its subtypes) located in CodeDomTest.dll. This class provides the test suite a single interface with which to call and handle your test. There is a subtype of CodeDomTest, namely CodeDomTestTree, that takes care of more details for you. The differences between the two are described below.

Writing a Test Case

Note in order to take advantage of the passed in options: saveassemblies and savesources, you must override CodeDomTestTree.

The CodeDomTest class requires you to override the following properties and methods:

Using CodeDomTestTree

Many CodeDom provider tests do the same kind of verification test. That is they:

  1. Build a CodeDom tree,
  2. Generate and compile code from it using the provider,
  3. then verify it using reflection or some other mechanism.

The CodeDomTestTree automates these three steps allowing you to focus on writing the test tree and verification. It also provides sub-scenario verification.

With these steps in mind, if you override CodeDomTestTree, the following methods should be implemented (note that you must still implement the three TestType, Name and Description properties):