Streamlining your automates tests, Pt. 2
Summary
While we do have a “builder method” creating our Test Context, the pattern’s purpose isn’t just to encapsulate the instantiation of a sole object. The payoff for adding the extra TextContext class and BuildHappyPathTestContext method is in completely removing the tangential setup concerns from the individual tests. While the Test context pattern is helpful in taming multiple aspects, it is extra code that we have to add and maintain, so we should make sure we realize the benefits. The key “code smell” of unnecessary usage is when the context object has properties with no verification checks against them. It’s pointless to shuttle around unused references in memory, and implies to future code readers that something is more important to our test than it really is.