7
votes
3answers
559 views

TDD Mock call verification - is it an anti-pattern?

I've been doing TDD for year now, I feel pretty good about it, I love my test suites and all. However I've noticed that lately I've been doing a lot of mock call verification. For example I'd have a ...
9
votes
2answers
648 views

Unit Testing: “It's a code smell if you're refactoring and there are no collaborators”?

I'm reading The Art of Unit Testing by Roy Osherove. I'm at section 7.2 Writing maintainable tests where the author has this note about code smell: NOTE: When you refactor internal state to be ...
1
vote
2answers
389 views

Unit Tests code duplication?

How can I avoid code duplication in unit tests? Using Java and JUnit suppose I have something like this: public interface Arithmetic<T> { public T add(T a, T b); public T sub(T a, T ...
1
vote
2answers
68 views

Should Multiple Data Items be in Multi Unit Test Methods?

I often want to have the same unit test applied to data multiple items that are roughly equivalent (two non-empty strings). Currently I implement these in multiple unit test methods, with names like ...
9
votes
5answers
593 views

Writing Testable Code vs Avoiding Speculative Generality

I was reading some blog posts this morning, and stumbled across this one: If the only class that ever implements the Customer interface is CustomerImpl, you don't really have polymorphism and ...
6
votes
3answers
415 views

Is having a switch to turn mocking on or off a code smell?

I have a method that looks like this: def foobar(mock=False, **kwargs): # ... snipped foobar actually makes several calls to Amazon S3 and returns a composed result. In order to make this ...
46
votes
12answers
3k views

If your unit test code “smells” does it really matter?

Usually I just throw my unit tests together using copy and paste and all kind of other bad practices. The unit tests usually end up looking quite ugly, they're full of "code smell," but does this ...
2
votes
2answers
179 views

Unit testing code paths

When unit testing using expectations, you define a set of method calls and corresponding results for those calls. These define the path through the method that you want to test. I have read that unit ...