blog-post-test-units-not-classes

http://blog.arkency.com/2014/09/unit-tests-vs-class-tests/

blog-post-test-units-not-classes#what-is-a-good-unit1 "A class doesn't usually make a good Unit, it's usually a collection of classes that is interesting." blog-post-test-units-not-classes#what-is-a-good-unit1

blog-post-test-units-not-classes#makes-requirements-clear1 2 Other people can enter the module and clearly see the requirements at the higher level blog-post-test-units-not-classes#makes-requirements-clear1 2

blog-post-test-units-not-classes#comment-i-left-on-article1

blog-post-test-units-not-classes#comment-i-left-on-article1

Test a facade-class, which has many classes that support it. Those supporting classes are not directly tested in the same way that private methods are not directly tested.

blog-post-test-units-not-classes#test-decoupled-from-implementation-details1 "When I add a new requirement to this module, I can add it as a test at the higher-level scope. When specifying the new test, I don't need to know how it's going to be implemented. It's a huge win, as I'm not blocked with the implementation structure yet. Writing the test is decoupled from the implementation details." blog-post-test-units-not-classes#test-decoupled-from-implementation-details1

A commenter on the blog post wrote this: "Meaning, do you test only the happy path, or do you test every possible data permutation that a user might have?"... because of the performance problems with high-level tests. We take integration test speed being slow as a given, but not so for mdpg.

blog-post-test-units-not-classes#nathan-ladd-comment1 The problem with the 1:1 class-to-test-file convention is that you're introducing mechanical friction that impedes redrawing boundaries within the objects that collaborate to produce a feature. In fact, I hear a lot of programmers refer to "the test" as being the file itself. This seems backwards. To me, a unit test is one of those methods that start with def test_* (or the it/specify block, if that is your tool of choice). It would be poor form for a test class to include unit tests that exercised the interfaces of different objects, but from time to time I'm satisfied when test coverage for an "inner object" lives in the "outer object's" test, by going through the outer object's API. Usually this happens when a project is getting started, and the ideal boundaries for objects is still unclear. blog-post-test-units-not-classes#nathan-ladd-comment1

Related

This seems related to testing-concept-get-object-state-by-watching-behavior

Basically the opposite viewpoint of talk-integration-tests-are-a-scam

Referring Pages

talk-integration-tests-are-a-scam testing-concept-test-units-not-classes testing-concept-stages-of-testing rails-facets testing-concept-get-object-state-by-watching-behavior testing-concept-class-to-test-file-convention enumerating-complex-scenarios

People

person-andrzej-krzywda