Official Murl Engine Forum

Full Version: Unit Testing with MURL
You're currently viewing a stripped down version of our content. View the full version with proper formatting.
Hey there Smile

I am using CppUnit to perform unit testing in my projects. Though everything is quite straight forward most of the time, unit testing gets difficult or better say more complicated when it comes to classes that are initialized over xml.

Examples for this would be a classes inheriting from Logic::GraphPositionInstance or classes containing/being custom nodes (e.g. http://murlengine.com/forum/showthread.php?tid=36 ).

Another problem arises when I want to test methods that modify the UI in some way.

So far I helped myself by creating custom constructors to be used in test cases and initializing only the most necessary stuff in order for the tests to work.

When it comes to methods manipulating the UI, I used preprocessor commands to disable UI interactions.
Example:
void ToggleButton::OnSetToInactive()
{
    Notify(Button::GetButtonId(), ToggleButton::Messages::SET_TO_INACTIVE);
#ifdef DRAW_GUI_ACTION
    TextTextureNode->SetBackgroundColor(Color(133.0f, 133.0f, 133.0f, 0.0f));
    ButtonNode->SetEnabled(false);
#endif
}

So much for explaining my approach...
Now to my questions.
  1. Is this is the correct/optimal way to perform unit testing with MURL?
  2. Would it be possible to also include methods that manipulate UI components into testing (e.g. SetBackgroundColor)?
  3. Are there any best practices or "dos and don'ts" you came across during your development?
As always, thank you!
[Image: 02-MultiMedical-1500x1500-1.png]