Go to the source code of this file.
Classes |
|
| class | UnitTest |
|
Base class for unit test objects. More... |
|
Namespaces |
|
| namespace | mudbox |
|
Class: ConvolutionKernel. |
|
Defines |
|
| #define | MB_START_TEST_OBJECT(testObjName) |
| These macros define a test object that
contains unit tests. |
|
| #define | MB_END_TEST_OBJECT(testObjName) |
| #define | MB_START_DEF_TESTS |
| #define | MB_END_DEF_TESTS }; |
| #define | MB_DECL_TEST(name) |
| #define | MB_DEF_TEST(name) |
| #define | MB_CHECK(condition) |
| #define MB_START_TEST_OBJECT | ( | testObjName | ) |
class testObjName : public UnitTest \ { \ static testObjName* s_pThis; \ DECLARE_CLASS; \ astring m_sCommand; \ testObjName() : m_sCommand(this, "cmd") { \ m_sCommand.Connect(Kernel()->NextCommand); \ Go(true,""); \ s_pThis = this; \ }; \ virtual ~testObjName() { \ if( s_pThis == this ) \ s_pThis = 0; \ }; \ void OnNodeEvent( const Attribute &cAttribute, NodeEventType eType ) { \ if( cAttribute == m_sCommand && eType == etValueChanged ) { \ QString sOp = m_sCommand.Value().section( ' ', 0, 0 ); \ if( sOp == "PluginTest" ) \ Go(false, m_sCommand.Value().section( ' ', 1, 1 )); \ }; \ }; \ static void RunAll() { \ if( s_pThis ) \ s_pThis->Go( false, "" ); \ }; \ static QString ClassName() { \ return #testObjName; \ };
These macros define a test object that contains unit tests.
To add unit tests to your plugin, put the following boilerplate code in a new .cpp file that gets compiled with your plugin.
#include <UnitTest.h> MB_START_TEST_OBJECT("Tester")
MB_DECL_TEST( TestName ) MB_DECL_TEST( TestName2 )
MB_START_DEF_TESTS MB_DEF_TEST( TestName ) { tests here } MB_DEF_TEST( TestName2 ) { tests here assert using MB_CHECK( some boolean expression ) to make sure your code is doing what you think its doing! } MB_END_DEF_TESTS
MB_END_TEST_OBJECT("Tester")
Definition at line 61 of file UnitTest.h.
| #define MB_END_TEST_OBJECT | ( | testObjName | ) |
}; IMPLEMENT_CLASS( testObjName, UnitTest, #testObjName ); \ testObjName* testObjName::s_pThis = 0;
Definition at line 91 of file UnitTest.h.
| #define MB_START_DEF_TESTS |
| #define MB_END_DEF_TESTS }; |
Definition at line 102 of file UnitTest.h.
| #define MB_DECL_TEST | ( | name | ) |
static void name() \ { \ Kernel()->RecordCommand( NTRQ("PluginTest %1%2").arg(ClassName()).arg(#name) ); \ if( s_pThis ) \ s_pThis->Go(false, ClassName() + QString(#name)); \ QString sMsg = NTRQ("Completed Test: %1").arg(ClassName() + QString(#name)); \ Kernel()->Log( sMsg ); \ Kernel()->Interface()->SetStatus( mudbox::Interface::stNormal, sMsg ); \ };
Definition at line 107 of file UnitTest.h.
| #define MB_DEF_TEST | ( | name | ) |