The task class is very much a self-contained entity and event driven; (i.e. files are added to watch folders and this is signaled by inotify) and an obvious way to test this would be to use google mock to simulate inotify events somehow. This may indeed happen when I get around to looking a mock more but it was decided to try a different approach.
After some thought it was decided to see if the class could be made easier to test through the addition of some new functionality and from this an extra task options parameter was born. It is optional, defaults to nullptr if not passed and is used to specify any useful functionality that may want to be added to the class.
Initially it will be used to add killCount functionality which just simply involves the task closing down after killCount files have been successfully processed ( the most obvious use to this is just to have a one pass task that stops after processing one file (killCount=1). With this extra functionality testing becomes a lot easier with just having to set the killCount to x and then create x files in the watch directory before the task stops.
With this a number number of unit tests where created that involved creating from 1 to 500 files to make sure that the task action function was called for each one. This was done by using a local task function that just incremented a count for each call and then test that count when the task has exited after the join for its thread.
Currently the rest of the classes tests follow a similar pattern to those for the task action functions and number with the file copy ones to around 10; which although on the low will grow as and when more are invented.