Difference between revisions of "Listing Functions and Test Units"

From STRIDE Wiki
Jump to: navigation, search
Line 1: Line 1:
While the STRIDE runner is mainly used to execute tests, it can also be used to list the test units that are available in a target build.  
+
==Overview==
 +
While the STRIDE runner is mainly used to execute tests, it can also be used to list the test units that are available in a target  
 +
build. The listing capability is useful in several scenarios:
  
 
* Verifying that a particular test unit is available in a specific build
 
* Verifying that a particular test unit is available in a specific build
Line 9: Line 11:
 
  stride --list --database TestApp.sidb
 
  stride --list --database TestApp.sidb
  
 +
==List Output==
 +
Test units are listed in the order they are encountered in the .sidb file (which reflects the order they were seen by the stride compiler when the target was built).
 +
 +
Each member test unit in the .sidb file is listed, with one test unit per line. A sample of this output from the TestIntro build is shown below.
 +
 +
<pre>
 +
s2_testintro_cclass
 +
s2_testintro_flist
 +
s2_testintro_testdoubles
 +
s2_testintro_testpoints
 +
</pre>
 +
 +
==Advanced List Usage==
 +
The list output can be piped to another program such as <tt>[http://en.wikipedia.org/wiki/Grep grep]</tt> in order to create a list of test units filtered by name characteristics.
 +
 +
For instance, suppose that you want to run only the test units owned by your department or development group from a target build that includes many tests aggregated from others. Provided that your test units follow a unique naming convention, you can create a filtered list as follows:
 +
 +
stride --list --database TestApp.sidb | grep myPrefix_*
 +
 +
Further, by redirecting the output to a file, you can create a stride command file with a little editing.
 +
 +
===Using Perl===
 +
You can automate the creation of a stride command file using perl.
 +
 +
<source lang="perl">
 +
while( <> ) {
 +
    if( /myPrefix_*/) {
 +
        print "-r $_";
 +
    }
 +
}
 +
</source>
 +
 +
The perl script shown above reads from stdin and attempts to match the line to the regular expression <tt>myPrefix_</tt>. If a match is detected, the line is written to stdout prefixed with <tt>-r </tt>,
 +
 +
If you save this script to a file named myTests.pl, you can automate the running of tests that match your prefix as follows:
 +
 +
stride --list --database TestApp.sidb | perl myTests.pl > tests.txt
 +
stride --database TestApp.sidb -O tests.txt
  
  
 
[[Category:Running Tests & Publishing Results]]
 
[[Category:Running Tests & Publishing Results]]

Revision as of 09:57, 28 August 2009

Overview

While the STRIDE runner is mainly used to execute tests, it can also be used to list the test units that are available in a target build. The listing capability is useful in several scenarios:

  • Verifying that a particular test unit is available in a specific build
  • Creating a command file that will be used to run only tests who's names match a specific text pattern
  • Creating a command file that will be used to run all tests in a particular order

To list the available test units, run stride giving it command line parameters as follows:

stride --list --database TestApp.sidb

List Output

Test units are listed in the order they are encountered in the .sidb file (which reflects the order they were seen by the stride compiler when the target was built).

Each member test unit in the .sidb file is listed, with one test unit per line. A sample of this output from the TestIntro build is shown below.

s2_testintro_cclass
s2_testintro_flist
s2_testintro_testdoubles
s2_testintro_testpoints

Advanced List Usage

The list output can be piped to another program such as grep in order to create a list of test units filtered by name characteristics.

For instance, suppose that you want to run only the test units owned by your department or development group from a target build that includes many tests aggregated from others. Provided that your test units follow a unique naming convention, you can create a filtered list as follows:

stride --list --database TestApp.sidb | grep myPrefix_*

Further, by redirecting the output to a file, you can create a stride command file with a little editing.

Using Perl

You can automate the creation of a stride command file using perl.

while( <> ) {
    if( /myPrefix_*/) {
        print "-r $_";
    }
}

The perl script shown above reads from stdin and attempts to match the line to the regular expression myPrefix_. If a match is detected, the line is written to stdout prefixed with -r ,

If you save this script to a file named myTests.pl, you can automate the running of tests that match your prefix as follows:

stride --list --database TestApp.sidb | perl myTests.pl > tests.txt
stride --database TestApp.sidb -O tests.txt