TestCase

From TinyOS Wiki
Revision as of 14:41, 21 December 2007 by Dmoss (talk | contribs) (Examples)
Jump to: navigation, search

Interface

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

Description

The TestControl and TestCase interfaces are identical in the commands and events they provide. This is to make it easier to program so interface names don't conflict.

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()!


Examples

 configuration MyTestC {
 }
 
 implementation {
   components MyTestP,
       new TestCaseC() as MyFirstTestC,
       new TestCaseC() as MySecondTestC;
       
   MyTestP.MyFirstTest -> MyFirstTestC;
   MyTestP.MySecondTest -> MySecondTestC;
 }


 #include "TestCase.h"
 
 module MyTestP {
   uses {
     interface TestCase as MyFirstTest;
     interface TestCase as MySecondTest;
   }
 }
 
 implementation {
 
   event void MyFirstTest.run() {
     assertTrue("False!", TRUE);
     call MyFirstTest.done();  // <-- IMPORTANT
   }
 
   event void MySecondTest.run() {
     assertEquals("You can't multiply", 9, 3*3);
     call MySecondTest.done();  // <-- IMPORTANT
   }
 }