Difference between revisions of "Training Advanced"

From STRIDE Wiki
Jump to: navigation, search
(Test Points)
(Fixtures)
Line 80: Line 80:
 
   stride --options_file my.opt --run "TestFixtures"
 
   stride --options_file my.opt --run "TestFixtures"
  
You can take a look at the results in '''TestApp.xml'''.
+
You can take a look at the results by opening the generated '''stride.html''' in your browser.
  
 
Consider the following for '''TryStuff:'''
 
Consider the following for '''TryStuff:'''
* Validate a test to validate "A", "B", and "C" using the "TRIGGER"
+
* Write a test to validate "A", "B", and "C" using the "TRIGGER"

Revision as of 17:31, 26 November 2014

The Advanced training focuses on using Test Doubles, Test Points, and Fixtures.

The Test Doubles will demonstrate how global functions can be dynamically intercepted and replaced with test logic (stub, fake, mock). The following functions contained in software_under_test will be used to demonstrate how to leverage interception when testing:

int sut_foo(int x);
int sut_boo(int x);
int sut_2xboo(int x);
int sut_strcheck(const char *s);

Test Points enable a different style of testing using source instrumentation. This is especially applicable when normal API testing is not practical. The following sequencing functions will be called that issue Test Points. Note that the sequencing routines are very simple, keeping the focus on the technique that can be applied.

void sut_Sequence1(void);
void sut_Sequence2(void);
void sut_Sequence3(void);

Fixturing shows how setup and teardown routines per test method can be incorporated within a Test Suite. The following functions will be used to demonstrate fixturing:

void sut_start_thread(void);
void sut_stop_thread(void);

Test Doubles

This test suite focuses on leveraging Test Doubles in the context of executing a test.

The following articles are related to this example:

The Test Suite is called TestDoubles and is implemented in two source files: testdoubles.cpp and testdoubles.h. The comments and descriptions are contained in the header file. Three test cases (methods) are already implemented and one test method that can be used to make changes to is called TryStuff. Currently the TryStuff test method is set to not in use.

First thing to do is run the TestDoubles Suite. Start the TestApp.exe and use the following command:

 stride --options_file my.opt --run "TestDoubles"

You can take a look at the results by opening the generated stride.html in your browser.

Consider the following for TryStuff:

  • Create your own stub for foo() and intercept it
    • confirm it returns what you expect
  • Double sut_boo()
    • call sut_2xboo() with a number
    • confirm within the test double (using a Test Macro) the expected passed in number (mocking example)

Test Points

This test suite focuses on Test Points and how to validate them.

The following articles are related to this example:

The Test Suite is called TestPoints and is implemented in two source files: testpoints.cpp and testpoints.h. The comments and descriptions are contained in the header file. Three test cases (methods) are already implemented and one test method that can be used to make changes to is called TryStuff. Currently the TryStuff test method is set to not in use.

First thing to do is run the TestPoints Suite. Start the TestApp.exe and use the following command:

 stride --options_file my.opt --run "TestPoints"

You can take a look at the results by opening the generated stride.html in your browser.

Consider the following for TryStuff:

  • Write a test to validate a subset of Test Points
  • Write a test to validate "E", "F", and "G", and a predicate to verify data associated with "E"

Fixtures

This test suite focuses on using Fixutures in the context of an executing Test Suite.

The following articles are related to this example:

The Test Suite is called TestFixtures and is implemented in two source files: testfixtures.cpp and testfixtures.h. The comments and descriptions are contained in the header file. One test cases (methods) is already implemented and one test method that can be used to make changes to is called TryStuff. Currently the TryStuff test method is set to not in use.

First thing to do is run the TestFixtures Suite. Start the TestApp.exe and use the following command:

 stride --options_file my.opt --run "TestFixtures"

You can take a look at the results by opening the generated stride.html in your browser.

Consider the following for TryStuff:

  • Write a test to validate "A", "B", and "C" using the "TRIGGER"