KnowledgeHub
Questions
Tags
Users
Search
Alex Rivera
|
Logout
Edit Question
Title
Body
I see two options for organizing PHPUnit unit tests into a namespace hierarchy. What are the advantages/disadvantages to these two approaches? Are there any obvious flaws I haven't considered that would make one the obvious better choice? Consider a sample class like \SomeFramework\Utilities\AwesomeClass : Approach 1: Place each TestCase class into the same namespace as the covered class. \SomeFramework\Utilities\AwesomeClassTest Advantages Consistent with the traditional approach to writing PHPUnit tests. Disadvantages Less flexibility. Seems to break the principle behind using namespaces - unrelated tests are grouped into the same namespace. Approach 2: Place each TestCase in a namespace named after the covered class. \SomeFramework\Utilities\AwesomeClass\Test Advantages Provides a very easy/obvious way to group multiple related TestCase classes together, say for different test suites. Disadvantages Could result in a deeper, more complex hierarchy.
Tags (comma-separated)
Save Edits
Cancel