Traditionally application code is written first and tests afterwards. After writing a piece of code, you write unit tests. And once you finished a few pieces of code, you write integration tests to see if they fit together. In Behavior-Driven development there is an approach called Outside-In Development where we go the other way round. Have a look at this screencast to learn more!