Training Fixturing: Difference between revisions

From STRIDE Wiki
Jump to navigation Jump to search
No edit summary
 
(13 intermediate revisions by 4 users not shown)
Line 1: Line 1:
= Objectives =
== 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 [[What_is_Unique_About_STRIDE#Fixturing | fixturing]]. This module focuses on the following topics:
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 [[What_is_Unique_About_STRIDE#Fixturing | fixturing]]. This module covers the following topics:
* Startup logic at the beginning of a Test Unit
* Startup logic at the beginning of a Test Unit
* [[Test_Unit_Pragmas#Fixturing_Pragmas | Setup]] logic for each test method
* [[Test_Unit_Pragmas#Fixturing_Pragmas | Setup]] logic for each test method
Line 13: Line 13:
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.  
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 =
== 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 not already done, create an [[Stride_Runner#Options | option file]] (myoptions.txt) using the following content (Windows example)
* If you have not created an option file, please refer to [[Training_Getting_Started#Run_Training_Tests| setup]]  
 
  ##### Command Line Options ######
  --device "TCP:localhost:8000"
  --database %STRIDE_DIR%\SDK\Windows\out\TestApp.sidb
  --output %STRIDE_DIR%\SDK\Windows\sample_src\TestApp.xml
  --log_level all


* Execute ''Test Fixture'' Test Unit only  
* Execute ''Test Fixture'' Test Unit only  


   > stride -O myoptions.txt --run TestFixture
   > stride -options_file myoptions.txt --run TestFixture


   Loading database...
   Loading database...
Line 42: Line 36:
   Saving result file...
   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.
* 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 ===


* '''TestFixture::Exercise1'''
* '''TestFixture::Exercise1'''
** 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 persisted when starting the Thread
** 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 59: Line 55:
* Execute only ''TestFixture''   
* Execute only ''TestFixture''   


   > stride -O myoptions.txt --run TestFixture
   > stride --options_file myoptions.txt --run TestFixture


   Loading database...
   Loading database...
Line 72: Line 68:
   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. To make it easier for now we recommend that you update your existing option file (myoptions.txt) with the following if not already done:
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]].


  #### Test Space options (partial) #####
   > stride --options_file myoptions.txt --run TestFixture --space TestFixture --upload
  #### Note - make sure to change username, etc. ####
  --testspace https://username:password@yourcompany.stridetestspace.com
  --project Training
  --name YOURNAME
 
   > stride -O myoptions.txt --run TestFixture --space TestFixture --upload


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 ===


* [[Test_Unit_Pragmas#Fixturing_Pragmas | Fixturing Pragmas]] -- important information for setting up and tearing down ''things'' between each executed test method within a Test Unit
* [[Test_Unit_Pragmas#Fixturing_Pragmas | 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  
** Review the types of Test Units these pragmas are applicable for  


== Samples ==
=== Samples ===


* [[Test_Class_Sample | Test Class Sample]] - Specifically the [[Test_Class_Sample#Basic::Fixtures | Basic Fixtures]] Test Unit
* [[Test_Class_Sample | Test Class Sample]] - Specifically the [[Test_Class_Sample#Basic::Fixtures | Basic Fixtures]] Test Unit

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