You are not logged in. Your edit will be placed in a queue until it is peer reviewed.
We welcome edits that make the post easier to understand and more valuable for readers. Because community members review edits, please try to make the post substantially better than how you found it, for example, by fixing grammar or adding additional resources and hyperlinks.
Required fields*
- 
        1"Unit tests are for testing the code of a single class." Sigh. That is not what unit tests are and following that guideline is either going to lead you into bloated classes or counterproductive, hindering tests.Ant P– Ant P2018-03-21 22:32:26 +00:00Commented Mar 21, 2018 at 22:32
 - 
        3treating "unit" as a euphemism for "class" is unfortunately a very common way of thinking but in reality all this does is (a) encourage "garbage-in, garbage-out" tests, which can totally undermine the validity of entire test suites and (b) enforce boundaries that should be free to change, which can cripple productivity. I wish more people would listen to their pain and challenge this preconception.Ant P– Ant P2018-03-21 22:40:44 +00:00Commented Mar 21, 2018 at 22:40
 - 
        3No such confusion. Test units of behaviour, not units of code. There is nothing about the concept of a unit test - except in the widespread cargo cult hive mind of software testing - that implies that a test unit is coupled to the distinctly OOP concept of a class. And a very damaging misconception that is, too.Ant P– Ant P2018-03-21 22:48:28 +00:00Commented Mar 21, 2018 at 22:48
 - 
        1I'm not sure precisely what you mean - I'm arguing the exact opposite of what you're implying. Stub/mock hard boundaries (if you absolutely have to) and test a behavioural unit. Through the public API. What that API is depends on what you're building but the footprint should be minimal. Adding abstraction, polymorphism or restructuring code should not cause tests to fail - "unit per class" contradicts this and utterly undermines the value of the tests in the first place.Ant P– Ant P2018-03-21 22:54:56 +00:00Commented Mar 21, 2018 at 22:54
 - 
        1RobbieDee - I'm talking about the precise opposite. Consider that you may be the one harbouring common misconceptions, revisit what you consider a "unit" and maybe dig a little deeper into what Kent Beck was actually really talking about when he talked about TDD. What most people call TDD now is a cargo cult monstrosity. youtube.com/watch?v=EZ05e7EMOLMAnt P– Ant P2018-03-22 08:29:21 +00:00Commented Mar 22, 2018 at 8:29
 
                    
                        
                    
                 | 
            
                Show 14 more comments
            
        
         
    How to Edit
        - Correct minor typos or mistakes
 - Clarify meaning without changing it
 - Add related resources or links
 - Always respect the author’s intent
 - Don’t use edits to reply to the author
 
        How to Format
    
    - 
                create code fences with backticks ` or tildes ~
                ```
like so
``` - 
                add language identifier to highlight code
                ```python
def function(foo):
print(foo)
``` - put returns between paragraphs
 - for linebreak add 2 spaces at end
 - _italic_ or **bold**
 - indent code by 4 spaces
 - backtick escapes 
`like _so_` - quote by placing > at start of line
 - to make links (use https whenever possible)
                <https://example.com>[example](https://example.com)<a href="https://example.com">example</a>
 
            How to Tag
        
        A tag is a keyword or label that categorizes your question with other, similar questions. Choose one or more (up to 5) tags that will help answerers to find and interpret your question.
- complete the sentence: my question is about...
 - use tags that describe things or concepts that are essential, not incidental to your question
 - favor using existing popular tags
 - read the descriptions that appear below the tag
 
If your question is primarily about a topic for which you can't find a tag:
- combine multiple words into single-words with hyphens (e.g. design-patterns), up to a maximum of 35 characters
 - creating new tags is a privilege; if you can't yet create a tag you need, then post this question without it, then ask the community to create it for you