We can always test it later, right?
An alternative approach to writing tests before code is to write code first, then write tests. This section compares and contrasts writing tests after the code with writing tests before the code.
One approach to writing tests involves writing chunks of code and then retrofitting tests to those pieces of code. It’s an approach that is used in commercial programming, and the workflow can be illustrated as follows:
Figure 12.3 – Test-after workflow
Upon selecting a user story to develop, one or more pieces of production code are written. Tests follow! Academic research seems mixed, to say the least, on whether or not test-after differs from test-first. From one 2014 study by the ACM, an extract from the conclusion was this: