TestControl

From TinyOS Wiki
Jump to: navigation, search

Interface

 interface TestControl {
   
   event void run();
   
   command void done();
   
 }

Description

The TestControl and TestCase interfaces are identical in the commands and events they provide.

The reason why there are two interfaces is to make it easy on the developer - you don't have to rename the TestCase interface and it won't conflict with TestControl interfaces. You do have to rename the TestControl interface as whatever you want to use it for. All TestControl interfaces - SetUpOneTime, SetUp, TearDown, and TearDownOneTime - are provided by any TestCaseC component you want to access. Each TestControl interface is optional to implement, but you should have at most one implementation of any of them if you choose to use it.

Any time you implement the run() event, you MUST call back to the interface that commanded the run() event and tell it you're done()!

The TestControl interface is found in tinyos-2.x-contrib/tunit/tos/interfaces/TestControl.nc

Examples

 configuration MyTestC {
 }
 
 implementation {
   components MyTestP,
       new TestCaseC() as MyFirstTestC;
   
   MyTestP.SetUpOneTime -> MyFirstTestC.SetUpOneTime;
   MyTestP.SetUp -> MyFirstTestC.SetUp;
   MyTestP.TearDown -> MyFirstTestC.TearDown;
   MyTestP.TearDownOneTime -> MyFirstTestC.TearDownOneTime;
   
   MyTestP.MyFirstTest -> MyFirstTestC;  // Note we don't have to specify the "TestCase" interface!
 }


 module MyTestP {
   uses {
     interface TestControl as SetUpOneTime;
     interface TestControl as SetUp;
     interface TestControl as TearDown;
     interface TestControl as TearDownOneTime;
     
     interface TestCase as MyFirstTest;
   }
 }