Difference between revisions of "Script Samples"

From STRIDE Wiki
Jump to: navigation, search
Line 7: Line 7:
 
* [[Perl Script APIs|perl Test Modules]]
 
* [[Perl Script APIs|perl Test Modules]]
  
== What is an expectation test ? ==
+
=== What is an expectation test ? ===
  
 
An expectation test is a test that validates behavior by verifying the occurrence (or non-occurrence) of specific test points on your running device. The STRIDE Framework makes it easy to define expectation tests ''via a single setup API'' ([[Perl_Script_APIs#Methods|see TestPointSetup]]) . Once defined, expectation tests are executed by invoking a ''wait'' method that evaluates the test points on the device as they occur. The wait method typically blocks until the entire defined expectation set has been satisfied '''or''' until a timeout (optional) has been exceeded.
 
An expectation test is a test that validates behavior by verifying the occurrence (or non-occurrence) of specific test points on your running device. The STRIDE Framework makes it easy to define expectation tests ''via a single setup API'' ([[Perl_Script_APIs#Methods|see TestPointSetup]]) . Once defined, expectation tests are executed by invoking a ''wait'' method that evaluates the test points on the device as they occur. The wait method typically blocks until the entire defined expectation set has been satisfied '''or''' until a timeout (optional) has been exceeded.
  
== How to I start my target processing scenario ? ==
+
=== How to I start my target processing scenario ? ===
  
 
It's often necessary, as part of test, to start the processing on the device that causes the test scenario to occur. Sometimes processing is invoked via external stimulus (e.g. send a command to a serial port or send a network message). Given the [http://search.cpan.org/ wealth of libraries] available for perl, it's likely that you'll be able to find modules to help you in automating common communication protocols.  
 
It's often necessary, as part of test, to start the processing on the device that causes the test scenario to occur. Sometimes processing is invoked via external stimulus (e.g. send a command to a serial port or send a network message). Given the [http://search.cpan.org/ wealth of libraries] available for perl, it's likely that you'll be able to find modules to help you in automating common communication protocols.  
Line 19: Line 19:
 
Whatever the approach, we strongly encourage test authors to find ways to minimize the amount of manual interaction required to execute expectation tests. Try to find ways to fully automate the interaction required to run your expectation scenarios. Fully automated tests are more likely to be run regularly and therefore provide a tighter feedback loop for your software quality.
 
Whatever the approach, we strongly encourage test authors to find ways to minimize the amount of manual interaction required to execute expectation tests. Try to find ways to fully automate the interaction required to run your expectation scenarios. Fully automated tests are more likely to be run regularly and therefore provide a tighter feedback loop for your software quality.
  
== Can I use test scripts for any other testing besides expectation validation? ==
+
=== Can I use test scripts for any other testing besides expectation validation? ===
  
 
'''Yes''' - STRIDE test modules provide a language-specific way to harness test code. If you have other procedures that can be automated using perl code on the host, then you can certainly use STRIDE test modules to harness the test code. In doing so, you will get the reporting conveniences that test modules provide (like automatic POD doc extraction, etc. and suite/test case generation) - as well as unified reporting with your other STRIDE test cases.
 
'''Yes''' - STRIDE test modules provide a language-specific way to harness test code. If you have other procedures that can be automated using perl code on the host, then you can certainly use STRIDE test modules to harness the test code. In doing so, you will get the reporting conveniences that test modules provide (like automatic POD doc extraction, etc. and suite/test case generation) - as well as unified reporting with your other STRIDE test cases.

Revision as of 16:06, 13 June 2011

Background

The STRIDE Framework allows you to write expectation tests that execute on the host while connected to a running device that has been instrumented with STRIDE Test Points. Host-based expectation tests leverage the power of scripting languages (perl is currently supported, others are expected in the future) to quickly and easily write validation logic for the test points on your system. What's more, since the test logic is implemented and executed on the host, your device software does not have to be rebuilt when you want to create new tests or change existing ones.

Please review the following reference articles before proceeding:

What is an expectation test ?

An expectation test is a test that validates behavior by verifying the occurrence (or non-occurrence) of specific test points on your running device. The STRIDE Framework makes it easy to define expectation tests via a single setup API (see TestPointSetup) . Once defined, expectation tests are executed by invoking a wait method that evaluates the test points on the device as they occur. The wait method typically blocks until the entire defined expectation set has been satisfied or until a timeout (optional) has been exceeded.

How to I start my target processing scenario ?

It's often necessary, as part of test, to start the processing on the device that causes the test scenario to occur. Sometimes processing is invoked via external stimulus (e.g. send a command to a serial port or send a network message). Given the wealth of libraries available for perl, it's likely that you'll be able to find modules to help you in automating common communication protocols.

If, on the other hand, the processing can be invoked by direct code paths in your application, you can consider using function fixturing via STRIDE. STRIDE function remoting allows you to specify a set of functions on the device that are to made available in the host scripting environment for remote execution. This can be a convenient way to expose device application hooks to the host scripting environment.

Whatever the approach, we strongly encourage test authors to find ways to minimize the amount of manual interaction required to execute expectation tests. Try to find ways to fully automate the interaction required to run your expectation scenarios. Fully automated tests are more likely to be run regularly and therefore provide a tighter feedback loop for your software quality.

Can I use test scripts for any other testing besides expectation validation?

Yes - STRIDE test modules provide a language-specific way to harness test code. If you have other procedures that can be automated using perl code on the host, then you can certainly use STRIDE test modules to harness the test code. In doing so, you will get the reporting conveniences that test modules provide (like automatic POD doc extraction, etc. and suite/test case generation) - as well as unified reporting with your other STRIDE test cases.

Samples

The following samples are available to illustrate the use of host scripting with the STRIDE Framework. They are a collection of native source under test and script test code code that demonstrate the techniques for creating and executing tests using the STRIDE Framework. These are the introductory samples for the STRIDE Framework that illustrate how to do expectation testing of instrumented source under test using script test modules on the host.

Once you have installed the STRIDE framework on your host machine, you can easily build and run any combination of these samples. In each case, you can include the source under test for the sample simply by copying its source files to the SDK's sample_src directory and rebuilding the off-target testapp.

Expectations Sample
This sample provides some pre-instrumented source code that include STRIDE Test Points and Test Logs. A single perl test module is included that implements a few examples of expectation testing based on the software under test. The process of including this sample as well as running it and publishing results is covered in Running and Publishing the Expectations Sample.
FileTransfer Sample
This sample shows an example of how you might use helper functions on the target to invoke STRIDE File Transfer services. The example is driven by host script logic that invokes remote target functions to actuate a file transfer to the target.
FunctionRemoting Sample
This sample shows some examples of invoking remote functions for the purpose of fixturing your behavior tests written in script on the host.