Writing factorized tests with datasets

We will now turn our attention to testing the Track class. We will focus specifically on the different states a Track class can have: STOPPED, PLAYING, and RECORDING. For each of these states, we want to make sure that adding SoundEvents works only if we are in the proper state (RECORDING).

To do so, we could write the following test functions:

  • testAddSoundEvent(): This function puts Track in the STOPPED state, calls track.addSoundEvent(0), and checks track.soundEvents().size == 0
  • testAddSoundEvent(): This function puts Track in the PLAYING state, calls track.addSoundEvent(0), and checks track.soundEvents().size == 0
  • testAddSoundEvent(): This function puts Track in the RECORDING state, calls track.addSoundEvent(0) ...

Get Mastering Qt 5 now with the O’Reilly learning platform.

O’Reilly members experience books, live events, courses curated by job role, and more from O’Reilly and nearly 200 top publishers.