blog-post-how-i-write-tests

https://news.ycombinator.com/item?id=13296589

Mentions his earlier post blog-post-design-for-testability

blog-post-how-i-write-tests#test-module-with-as-few-dependencies-as-possible "How can I design units that are testable with as few dependencies as possible?" blog-post-how-i-write-tests#test-module-with-as-few-dependencies-as-possible

blog-post-how-i-write-tests#avoid-running-main1 When developing a new project, or adding a feature, there's a very strong instinct to start with manual testing – to run the binary and test the new feature by hand.

I try very hard to resist this urge blog-post-how-i-write-tests#avoid-running-main1

When talking about fakes, he recommends this talk talk-stop-mocking-start-testing-google-code-devs

blog-post-how-i-write-tests#programmable-fake1 If your interface is too complex, you can still provide a "programmable" fake that lets tests configure or plug in its behavior in appropriate ways, instrucing it how to respond to inputs. Such a fake still provides value by structuring testing, and sharing lower-level, ancillary details of implementing the interface. blog-post-how-i-write-tests#programmable-fake1

blog-post-how-i-write-tests#miniformats1 2 3 One powerful technique can be to design and implement a small textual format for representing your data (either internal state objects, or structured input), that is easily human readable and writable. Then, augment your tests and application so that you can easily input or print objects using this format. blog-post-how-i-write-tests#miniformats1 2 3

blog-post-how-i-write-tests#minilanguage-or-zoo1

building a completely data-driven test harness that lets you express common types of test cases entirely as data files in a directory, without adding any additional code. Done right, this lets you add new test cases directly in a familiar format, and even directly translate bug reports or interactive tests into test cases.

(A coworker calls this pattern a "zoo", because you get one directory containing all of your exotic animals, and I've adopted that nickname)

blog-post-how-i-write-tests#minilanguage-or-zoo1

One of the commenters mentioned that he wrote a blog post about the zoo-style testing: blog-post-baseline-testing

Referring Pages

using-an-ascii-diagram-as-data testing-concept-fakes-instead-of-stubs-or-mocks testing-concept-programmable-fake testing-concept-miniformats-for-test-input-and-output testing-concept-minilanguage-or-zoo testing-concept-avoid-running-main

People

person-nelson-elhage