Wednesday, May 21, 2014

Embedded Test framewrok

Embedded Test Frame work memo:
- embUnit
 #include 

- Test definition:

static void setup(void) {}
static void teardown(void {}

static void test_func1(void){
 // Test for funcA
 TEST_ASSERT_EQUAL_STRING(exp, actual)
 ...
}

static void test_func2(void){
 // Test for funcA
 TEST_ASSERT_EQUAL_STRING(exp, actual)
 ...
}
...

TestRef Testset_A(void){
 EMB_UNIT_TESTFIXTURE(fixture){
  new_TestFixture("test_func1", test_func1);
  new_TestFixture("test_func2", test_func2);
  ...
 }
 
 // Create a test called "Testname_A"
 EMB_UNIT_TESTCALLER(Testname_A, "Testname_A", setup, teardown, fixtures);
 
 return (TestRef)&Testname_A;
}

Run Test:
#include 

TestRef Testset_A(void);
...

int main(int argc, const char** argv)
{
 TestRunner_start();
 TestRunner_runTest( Testset_A () );
 ...
 TestRunner_end();
 return 0;
}




No comments: