I'm unit testing code that deals with the delegation of time-sensitive tasks to casual workers with variable hours of availability. The general answer I'm after, however, should be independent of this context.
So, I'll have tests which follow this structure:
Test Task 1 is delegated to Bob under Specific Condition X:
- Check Task 1 gets delegated to Frank
- Create specific condition X
- Test Task 1 gets delegated to Bob now, instead.
My question is, is step 1 superfluous? I already have another tests that checks step 1 alone (that under no specific conditions, the task gets delegated to Frank).
However, adding step 1 made me feel secure that my test is in fact testing the exact right thing - I verify that the result changes under condition X.
Here's another more specific example:
Test Tasks aren't delegated if no one is available
- Create availabilities, and check tasks are delegated
- Remove availabilities, and check tasks are NOT delegated
Again, is step 1 overkill? I already have a test to test for step 1, on it's own:
Test Tasks ARE delegated if people ARE available
- Create availabilities, and check tasks are delegated
So, is it stupid to re-test that scenario in the previous example, just be make extra certain?
I initially (some time ago) thought it was a good idea, but reading my code now, it seems like overkill. But I want to be certain before deleting a whole bunch of code from my test suite!
Thanks!