While practicing TDD, I came across this specification:
A user should be created with its password hashed, be persisted and an activation token should be returned.
Should my first unit test, (aiming to begin to test this scenario) should encompass the whole needs? :
Or rather, splitting its main parts into several smaller tests, and testing incrementally:
shouldCreateAUser shouldReturnAUserActivationToken shouldReturnAnActivationTokenBasedOnNewlyCreatedUserEmail shouldPersistTheNewlyCreatedUser shouldHashTheUserPersistBeforePersistingIt
To put in a nutshell, should I rework the same test until a whole scenario passes? Or should I proceed incrementally by specifying additional features in other small tests.
IMHO, the benefit of the first solution is that the spec is defining in one place, no need to gather some chuncks of features to figure out the whole. On the other hand, the number of assertions and expectations might be huge, therefore the test code would be less readable.