Difference between revisions of "TestCase"

From TinyOS Wiki
Jump to: navigation, search
(New page: == Interface == interface TestCase { event void run(); command void done(); } == Description == The TestControl and TestCase interfaces are identical in...)
 
(Examples)
Line 33: Line 33:
  
 
   #include "TestCase.h"
 
   #include "TestCase.h"
 
+
 
 
   module MyTestP {
 
   module MyTestP {
 
     uses {
 
     uses {

Revision as of 13:41, 21 December 2007

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