Nobody plans to write smelly tests...

Just getting started with automated unit testing? Study all you want, but you’ll eventually walk into a code situation that you weren’t well-prepared for.

For example, you inherit some nasty code and your boss wants you to cover 50% of it with tests. You know code smells create test smells and you’re worried…

“this object validates input AND does data access… that’ll be a gnarly test”

“I need a comparison method for this ‘God Object’ for assertions… should I add the method to production code?”

“guess I need mocking framework, but the docs use Repositories… do I have to write Repositories now!?”

Being new to testing - how do you know what pitfalls to avoid? How do you prevent test smells? How do you detect test smells the first place?

Aren’t Tests Supposed to Make Refactoring Easier?

Say you go ahead and write a test for that object validates input AND does data access scenario… are you sure you tested it correctly? You thought tests make refactoring easier, not create more refactoring work!

You Need a Test Quality Strategy

Imagine writing awesome unit tests as if you’ve been doing it for years. What if that smelly codebase started to improve as soon as you took ownership of it? Your tests would unearth and eliminate smells, making it work and keeping it simple… just how your boss wants it.

What if you could sense Test Smells like Hard-to-Test Code from a mile away. The relationship between your tests and code would be mutually beneficial - your tests would improve the code and your code would facilitate testing.

What if you could look at any existing test code and pick up patterns and smells that are only visible to the trained eye. What if you could gain this sharp sense within a few minutes?

Make your Tests Show your Code’s Greatness

There is always the risk of writing a Test Smell, but what if you could completely rely on the correctness of your tests. You would be confident that your tests always contribute to the greatness of the code.

Sense Test Smells before they Happen with my Cheat Sheet: “Test Smells: Root Causes”

Grow your Test Smell senses with my visual cheat sheet: Test Smells: Root Causes. xUnit Test Patterns: Refactoring Test Code by Gerard Meszaros, provided us with a catalog of Test Smells and their Root Causes.

Test Smells: Root Causes is a FREE visual cheat sheet that shows you each Test Smell from xUnit Test Patterns and its potential Root Cause(s).

Be Reminded of what Good Testing Habits can Prevent

You’ll gain quick access to the common pitfalls that cause Test Smells and start writing better tests. Even the smelliest code will be easier to write tests for because you’re building good, future-proof testing habits.

Click the link below, enter your name and email address, print each of the 3 visual cheat sheet PDFs, and tape them to your wall.

You’ll have a constant reminder of some of the major reasons why test code can get smelly.

Tweet
comments powered by Disqus