I saw a programming habit where the test code was written immediate before the function so that test and function are always together. This makes me wonder why do some projects separates tests to separate file? What are pros and cons of different approaches?