What is the difference between writing a unit test in the same class as the tested method or writing it in another class (of the same package or extern package)?
What are the advantages or disadvantages of these test-locations?
What is the difference between writing a unit test in the same class as
Share
There is not “right” answer for this question.
Writing in the same class:
Allows you to test private methods but mess up the code.
Writing in the same project:
Allows you to test internal methods/logics but mess up the project and extends your compilation time.
Writing externally:
Prevents you from testing project internal methods/classes but keeps the tests clean and external to your “production” coder.