Testing, FontAwesome and some code

I spent the day playing with ways of writing automated tests for UI components, and integrations of UI components.  

In the process I also wrote a clone of the Bootstrap Alerts window, a bunch of little utility classes and most usefully a embedded FontAwesome setup for JUCE (this is probably the most useful bit!).

The stuff is on:


Pick it to pieces please!  (I have probably missed some useful technique...)


  • Automated UI tests are more useful than I thought.  I picked up bugs as I was modifying the code just today.
  • Labelling of components with ComponentIDs makes it easy to identify basic behaviours.  
  • It might be useful to navigate the component tree and use dynamic_cast to access otherwise 'private' subcomponents for testing.  I've not tried this yet.
  • PopupMenu is a pain to test unless you careful expose a handlePopupMenu selection function.

Also, small tweaks to JUCE would help:

  • It'd be great if the JUCER could also create a _Tests.cpp file when creating other types of source file. 
  • It'd be great if the JUCER could create plain text files for other programming languages, scripts and so on.
  • And a small thing: The assertion in the UnitTest class is on the wrong line.  If something (horrible) could be done with macros to make the assertion actually happen in the UnitTest that would be great.  It may not be a problem when your tests are usually passing - but when you've got lots of them and they break often it's a pain to have to hit the call stack each time... 

Next up - automated audio tests ;-)


Great stuff. I think automated UI tests are really useful, and almost essential for larger projects (coming from my web development experience). Would be great to have this as a seperate module, and ultimately as part of JUCE. 

EDIT: In fact it would be an awesome addition to Projucer to be able to live build and run your tests as you write your app's classes, with the classic red=fail and green=pass feedback. 

Interesting. How do you perform automated GUI tests? Do you remote control the mouse from your test procedure?

Awesome! FYI, I was taking a look at UiUnitTests.h and thought you might like to know about Component::findChildWithID, seems like it'd simplify your code a little.

Joshua - I did try that first but I'm not sure it's recursive!.  Certainly it didn't work for me ... though I could have been holding the wrong end or something... 

Thanks for sharing ! Embedding Font Awesome in a JUCE class is a very good and useful idea

I take it for granted a little bit, that the mouse handling will work, and test from the next best location.  

So it's not a complete simulation. But it's a lot closer to the GUI than my tests have ever been before ...

Have you seen danlin's FontAwesome module? https://github.com/danlin/danlin_modules

Ah - bloody hell - I missed that entirely !

I'll put it in the package manager ;-)