Test Class Sample: Difference between revisions

From STRIDE Wiki
Jump to navigation Jump to search
No edit summary
Line 19: Line 19:


Now that you have built the off-target simulator and run the test classes it contains, you can take time to peruse the test class source and the corresponding results that each produces.  This section provides a brief description for each.
Now that you have built the off-target simulator and run the test classes it contains, you can take time to peruse the test class source and the corresponding results that each produces.  This section provides a brief description for each.
''NOTE:'' each of the example test classes we provide is grouped in namespace corresponding to its top-level category (e.g. ''Basic'' or ''Runtime Services'').  This is something we have chosen to do for organizational purposes only -- it is '''not''' a general requirement that test classes be placed into namespaces. 


===Basic Examples===
===Basic Examples===
These examples cover the simplest, easiest way to code a STRIDE test class. These examples use simple [http://en.wikipedia.org/wiki/Plain_Old_Data_Structures POD] return types to indicate status and do not annotate the tests with any rich information (such as comments).


====01_01_Basic_Simple====
====01_01_Basic_Simple====
Demonstrates passing and failing tests using the four primary POD types that we can infer status from (int, bool, short, and char).


====01_02_Basic_Fixtures====
====01_02_Basic_Fixtures====
Demonstrates the use of [[Test_Units#Pragmas_for_Test_Units|setup and teardown]] fixtures.  The setup and teardown methods are called immediately before and after the execution of each test method, respectively.


====01_03_Basic_Exceptions====
====01_03_Basic_Exceptions====

Revision as of 04:49, 19 July 2008

Introduction

The following content relates to the sample files and workspaces installed in %STRIDE_DIR%\Samples\TestUnits\TestClass. This sample consists of a Visual Studio workspace for building an off-target simulator, sample test class source code, and a STRIDE workspace for doing more advanced test class execution.

Getting Started

To begin, open the Visual Studio Solution file in the sample directory. This solution (and corresponding project) were created for Visual Studio 2005. If you have a later version of Visual Studio installed, you should be able to open this solution and it will be automatically upgraded if necessary. If you do not currently have any version of Visual Studio, we recommend that you install the current free (as in beer) version of Visual Studio Express.

Once you have successfully opened the solution, rebuild it. The build process has custom STRIDE build rules integrated and will produce a STRIDE database, intercept module source files, and an off-target simulator application that incorporates the test class source.

Once the build is complete, perform the following steps to run the test classes in the workspace:

  1. launch the off-target simulator, TestClass.exe. This will run in a standard console window.
  2. open a command prompt window and change to this sample's directory.
  3. at the command prompt, run the command TestUnitRun.pl -v. This will execute all of the test units in the workspace and open a browser to display the results.
  4. quit the TestClass.exe application by typing 'q' in its console window.

Sample Test Classes

Now that you have built the off-target simulator and run the test classes it contains, you can take time to peruse the test class source and the corresponding results that each produces. This section provides a brief description for each.

NOTE: each of the example test classes we provide is grouped in namespace corresponding to its top-level category (e.g. Basic or Runtime Services). This is something we have chosen to do for organizational purposes only -- it is not a general requirement that test classes be placed into namespaces.

Basic Examples

These examples cover the simplest, easiest way to code a STRIDE test class. These examples use simple POD return types to indicate status and do not annotate the tests with any rich information (such as comments).

01_01_Basic_Simple

Demonstrates passing and failing tests using the four primary POD types that we can infer status from (int, bool, short, and char).

01_02_Basic_Fixtures

Demonstrates the use of setup and teardown fixtures. The setup and teardown methods are called immediately before and after the execution of each test method, respectively.

01_03_Basic_Exceptions

01_04_Basic_Constructors

Runtime Services Examples

02_01_RuntimeServices_Simple

02_02_RuntimeServices_Dynamic

02_03_RuntimeServices_Override

02_04_RuntimeServices_VarComment

srTest Examples

03_01_srTest_Simple

03_02_srTest_Dynamic

Test Class Execution

Command Line Execution

Workspace-Based Execution