codemonkey
codemonkey

Reputation: 608

Spring Test Driven Development Mocking

TDD veterans seem to suggest that we must avoid mocking 3rd party code such as any framework code. Any non-trivial Spring based project will have dozens of Spring provided Beans injected and used. If Mocking 3rd party code is bad, what is the best way to write Unit Tests when the class depends on Spring provided Beans?

Upvotes: 1

Views: 76

Answers (1)

Raedwald
Raedwald

Reputation: 48634

Don't mock then, use the real classes! Just as you wouldn't mock the String class.

That said, if you are developing a web application or a REST client, you should be aware that Spring provides classes that mock the web application server, for testing web applications, and the HTTP client, for testing REST clients.

Upvotes: 1

Related Questions