For smaller projects this would be better
Suggest you never do that. If you're writing unit tests, then your unit is a class. One unit test for one class. That's the purpose of a "unit test". When you mix different unit's functionality to be tested in a single source file, it's definitely not the way your colleagues expect it to be. If you're about to test functionality of two or more classes working together then you're doing not a "unit testing". In such case those tests (integration or function) should reside separately from unit tests. And there's another more important reason to place your unit tests in a separate source set: unit test usually have simpler pre-requisites for running (mocking and stubbing) than other types of tests (some parts of live system or all the system). Just google, here's the first search result I got: http://softwaretestingfundamentals.com/unit-testing/
Обсуждают сегодня