Training Fixturing: Difference between revisions
(3 intermediate revisions by the same user not shown) | |||
Line 19: | Line 19: | ||
* [[Building_an_Off-Target_Test_App#Build_Steps | Build TestApp]] using SDK makefile | * [[Building_an_Off-Target_Test_App#Build_Steps | Build TestApp]] using SDK makefile | ||
* Startup TestApp | * Startup TestApp | ||
* If not | * If you have not created an option file, please refer to [[Training_Getting_Started#Run_Training_Tests| setup]] | ||
* Execute ''Test Fixture'' Test Unit only | * Execute ''Test Fixture'' Test Unit only | ||
Line 49: | Line 43: | ||
** Add a ''NOTE'' that will display the ''name'' of the test. | ** Add a ''NOTE'' that will display the ''name'' of the test. | ||
** Validate that '''Sequence2''' is stored when starting the Thread by checking that "Sequence2" equals MyString[0]. | ** Validate that '''Sequence2''' is stored when starting the Thread by checking that "Sequence2" equals MyString[0]. | ||
** | *** ''HINT'': The method to focus on in SUT is DoSequencing() | ||
*** ''HINT'': m_sequence is incremented as each method goes through Teardown. | |||
* '''TestFixture::Exercise2''' | * '''TestFixture::Exercise2''' | ||
Line 75: | Line 70: | ||
=== Run and Publish Results === | === Run and Publish Results === | ||
When you have completed the Exercise(s) publish your results to Test Space. | When you have completed the Exercise(s) publish your results to Test Space (--space TestFixture). If you have not added test space options to your options file (<tt>myoptions.txt</tt>) please see [[Training_Getting_Started#Test_Space_Access| testspace access]]. | ||
> stride --options_file myoptions.txt --run TestFixture --space TestFixture --upload | > stride --options_file myoptions.txt --run TestFixture --space TestFixture --upload |
Latest revision as of 21:25, 31 January 2013
Objectives
This Training Module focuses on Fixturing in the context of the STRIDE Test System. For a high-level overview refer to the following wiki section on fixturing. This module covers the following topics:
- Startup logic at the beginning of a Test Unit
- Setup logic for each test method
- Teardown logic for each test method
There are two test files used -- TestFixture.cpp & TestFixture.h. These implement one Test Unit:
- TestFixture
The Test Unit has one test case already implemented (used for reference) and has two test methods that you are required to implement (called Exercise1 and Exercise2). Currently the Exercise1 method is empty and returns a NOT IN USE status. The Exercise2 method does not yet exist.
Instructions
Build and Run TestApp
- Build TestApp using SDK makefile
- Startup TestApp
- If you have not created an option file, please refer to setup
- Execute Test Fixture Test Unit only
> stride -options_file myoptions.txt --run TestFixture
Loading database... Connecting to device... Executing... test unit "TestFixture" > 1 passed, 0 failed, 0 in progress, 1 not in use. -------------------------------------------------------------- Summary: 1 passed, 0 failed, 0 in progress, 1 not in use. Disconnecting from device... Saving result file...
- Review the details of the test results using a Browser. Open TestApp.xml which can be found in the sample_src directory (based on the output option). By opening the xml file in a web browser the xsl is automatically applied to create html.
Implement Exercise
- TestFixture::Exercise1
- Add a NOTE that will display the name of the test.
- Validate that Sequence2 is stored when starting the Thread by checking that "Sequence2" equals MyString[0].
- HINT: The method to focus on in SUT is DoSequencing()
- HINT: m_sequence is incremented as each method goes through Teardown.
- TestFixture::Exercise2
- Add new test method declaration called Exercise2 to TestFixture.h
- Add new test method implementation of Exercise2 to TestFixture.cpp
- Add a NOTE that will display the name of the test
- Validate that Sequence3 is persisted when starting the Thread
- Execute only TestFixture
> stride --options_file myoptions.txt --run TestFixture
Loading database... Connecting to device... Executing... test unit "TestFixture" > 3 passed, 0 failed, 0 in progress, 0 not in use. -------------------------------------------------------------- Summary: 3 passed, 0 failed, 0 in progress, 0 not in use. Disconnecting from device... Saving result file...
Run and Publish Results
When you have completed the Exercise(s) publish your results to Test Space (--space TestFixture). If you have not added test space options to your options file (myoptions.txt) please see testspace access.
> stride --options_file myoptions.txt --run TestFixture --space TestFixture --upload
Note: This space has been set up with a Baseline of expected test results that you can use to validate your results.
Reference
The following reference information is related to passing parameters to Test Units.
Wiki
- Fixturing Pragmas -- important information for setting up and tearing down things between each executed test method within a Test Unit
- Review the types of Test Units these pragmas are applicable for
Samples
- Test Class Sample - Specifically the Basic Fixtures Test Unit
- Test C Class Sample - Specifically the Basic Fixtures Test Unit
- Test Function List Sample- Specifically the Basic Fixtures Test Unit