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...)
 
(Description)
 
(One intermediate revision by the same user not shown)
Line 15: Line 15:
 
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()!
 
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 TestCase interface can be found in [http://tinyos.cvs.sourceforge.net/*checkout*/tinyos/tinyos-2.x-contrib/tunit/tos/interfaces/TestCase.nc?content-type=text%2Fplain tinyos-2.x-contrib/tunit/tos/interfaces/TestCase.nc]
  
 
== Examples ==
 
== Examples ==
Line 33: Line 34:
  
 
   #include "TestCase.h"
 
   #include "TestCase.h"
 
+
 
 
   module MyTestP {
 
   module MyTestP {
 
     uses {
 
     uses {

Latest revision as of 15:18, 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()!

The TestCase interface can be found in tinyos-2.x-contrib/tunit/tos/interfaces/TestCase.nc

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