Training Parameters: Difference between revisions
(Created page with '= Objectives = This Training Module is focused on '''Parameter passing''' in the context of the Test Unit. The module focuses on the following: * [[Parameterized_Test_Units | Pa…') |
|||
(13 intermediate revisions by 4 users not shown) | |||
Line 1: | Line 1: | ||
= Objectives = | == Objectives == | ||
This Training Module is focused on '''Parameter passing''' in the context of the Test Unit. The module | This Training Module is focused on '''Parameter passing''' in the context of the Test Unit. The module covers the following: | ||
* [[Parameterized_Test_Units | Passing parameters]] via the Runner | * [[Parameterized_Test_Units | Passing parameters]] via the Runner | ||
There are two test files used -- '''TestParam.cpp & TestParam.h''' | There are two test files used -- '''TestParam.cpp & TestParam.h'''. These implement one Test Unit: | ||
* '''TestParam''' | * '''TestParam''' | ||
The Test Unit has test cases already implemented (used for reference) and has one test method that you are required to implement (called '''Exercise'''). Currently this method is empty and | The Test Unit has test cases already implemented (used for reference) and has one test method that you are required to implement (called '''Exercise'''). Currently this method is empty and returns a ''NOT IN USE'' status. | ||
= Instructions = | == Instructions == | ||
== Build and Run TestApp == | === Build and Run TestApp === | ||
* Build TestApp using SDK makefile | * [[Building_an_Off-Target_Test_App#Build_Steps | Build TestApp]] using SDK makefile | ||
* Startup TestApp | * Startup TestApp | ||
* | * If you have not created an option file, please refer to [[Training_Getting_Started#Run_Training_Tests| setup]] | ||
* Execute ''Test Param'' Test Unit only | * Execute ''Test Param'' Test Unit only | ||
: Note that parameters are passed to the test unit from the host command line. | |||
> stride - | > stride --options_file myoptions.txt --run "TestParam(9,4,\"STRING1\")" | ||
Loading database... | Loading database... | ||
Line 40: | Line 35: | ||
Saving result file... | Saving result file... | ||
* Review the details of the test results using a Browser. Open | * Review the details of the test results using a Browser. Open [[Building_an_Off-Target_Test_App#Interpreting_Results | 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 == | === Implement Exercise === | ||
* Add a ''NOTE'' | ;Exercise() | ||
* Add Assert macro guarding against no parameters being passed (i.e. 0 received) | * Add a ''NOTE'' that will display the ''integer parameters'' passed via command line | ||
* Call ''sut_add()'' with parameters and validate it returns expected value | * Add an Assert macro guarding against no parameters being passed (i.e. default value of 0 received) | ||
* Call ''sut_mult()'' with parameters and validate it returns expected value | * Call ''sut_add()'' with parameters and validate that it returns the expected value | ||
* Call ''sut_mult()'' with parameters and validate that it returns the expected value | |||
** ''Hint:'' You will probably want to read about [[Parameterized Test Units]] | |||
* Execute only ''TestParam'' '''without''' parameters | * Execute only ''TestParam'' '''without''' parameters | ||
> stride - | > stride --options_file myoptions.txt --run TestParam | ||
Loading database... | Loading database... | ||
Line 67: | Line 64: | ||
* Execute only ''TestParam'' '''with''' parameters | * Execute only ''TestParam'' '''with''' parameters | ||
> stride -O myoptions.txt --run TestParam(9,4,\"STRING1\") | > stride -O myoptions.txt --run "TestParam(9,4,\"STRING1\")" | ||
Loading database... | Loading database... | ||
Line 80: | Line 77: | ||
Saving result file... | Saving result file... | ||
== 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 TestParam). 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 "TestParam(9,4,\"STRING1\")" --space TestParam --upload | |||
> stride - | |||
Note: This space has been set up with a Baseline of [[Training_Getting_Started#Test_Space_Access | ''expected test results'']] that you can use to validate your results. | Note: This space has been set up with a Baseline of [[Training_Getting_Started#Test_Space_Access | ''expected test results'']] that you can use to validate your results. | ||
= Reference = | == Reference == | ||
The following reference information is related to passing parameters to Test Units. | The following reference information is related to passing parameters to Test Units. | ||
== Wiki == | === Wiki === | ||
* [[Parameterized_Test_Units |Parameterized Test Units]] - Describes how to supply parameters to your Test Units | * [[Parameterized_Test_Units |Parameterized Test Units]] - Describes how to supply parameters to your Test Units | ||
Line 104: | Line 95: | ||
** Review <tt>run[--r] arg</tt> option | ** Review <tt>run[--r] arg</tt> option | ||
== Samples == | === Samples === | ||
* [[Test_Class_Sample | Test Class Sample]] - Specifically the [[Test_Class_Sample#Basic::Parameterized | Parameterized]] Test Unit | * [[Test_Class_Sample | Test Class Sample]] - Specifically the [[Test_Class_Sample#Basic::Parameterized | Parameterized]] Test Unit | ||
* [[Test_CClass_Sample | Test C Class Sample]] - Specifically the [[Test_CClass_Sample#basic_parameterized | Parameterized]] Test Unit | * [[Test_CClass_Sample | Test C Class Sample]] - Specifically the [[Test_CClass_Sample#basic_parameterized | Parameterized]] Test Unit |
Latest revision as of 21:24, 31 January 2013
Objectives
This Training Module is focused on Parameter passing in the context of the Test Unit. The module covers the following:
- Passing parameters via the Runner
There are two test files used -- TestParam.cpp & TestParam.h. These implement one Test Unit:
- TestParam
The Test Unit has test cases already implemented (used for reference) and has one test method that you are required to implement (called Exercise). Currently this method is empty and returns a NOT IN USE status.
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 Param Test Unit only
- Note that parameters are passed to the test unit from the host command line.
> stride --options_file myoptions.txt --run "TestParam(9,4,\"STRING1\")"
Loading database... Connecting to device... Executing... test unit "TestParam" > 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
- Exercise()
- Add a NOTE that will display the integer parameters passed via command line
- Add an Assert macro guarding against no parameters being passed (i.e. default value of 0 received)
- Call sut_add() with parameters and validate that it returns the expected value
- Call sut_mult() with parameters and validate that it returns the expected value
- Hint: You will probably want to read about Parameterized Test Units
- Execute only TestParam without parameters
> stride --options_file myoptions.txt --run TestParam
Loading database... Connecting to device... Executing... test unit "TestParam" > 0 passed, 2 failed, 0 in progress, 0 not in use. -------------------------------------------------------------- Summary: 0 passed, 2 failed, 0 in progress, 0 not in use. Disconnecting from device... Saving result file...
- Execute only TestParam with parameters
> stride -O myoptions.txt --run "TestParam(9,4,\"STRING1\")"
Loading database... Connecting to device... Executing... test unit "TestParam" > 2 passed, 0 failed, 0 in progress, 0 not in use. -------------------------------------------------------------- Summary: 2 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 TestParam). If you have not added test space options to your options file (myoptions.txt) please see testspace access.
> stride --options_file myoptions.txt --run "TestParam(9,4,\"STRING1\")" --space TestParam --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
- Parameterized Test Units - Describes how to supply parameters to your Test Units
- STRIDE Runner - Information on command line options
- Refer to "Test Unit Specification Examples" - specifically examples using parameters
- Review run[--r] arg option
Samples
- Test Class Sample - Specifically the Parameterized Test Unit
- Test C Class Sample - Specifically the Parameterized Test Unit