Welcome to the Treehouse Community

Want to collaborate on code errors? Have bugs you need feedback on? Looking for an extra set of eyes on your latest project? Get support with fellow developers, designers, and programmers of all backgrounds and skill levels here with the Treehouse Community! While you're at it, check out some resources Treehouse students have shared here.

Looking to learn something new?

Treehouse offers a seven day free trial for new students. Get access to thousands of hours of content and join thousands of Treehouse students and alumni in the community today.

Start your free trial

Java

Karrtik Iyer
Karrtik Iyer
3,738 Points

TDD with Spring MVC

I know how we do TDD with plain java code using JUNIT, however it would be good to know while doing the Spring MVC videos/courses as to how should we approach TDD when working with frameworks such as Spring? Should we consider controller as unit and write cases for each URL mapping? Please advise. I guess for the model part if it is a POJO or reading from file or DB, we can write tests or stubs for them before we code them up as part of TDD, however not sure about the controller and view part. I guess we can also inspect the modelmap to see if controller did its job and call the controller in the way we normally write JUNIT tests. But I was wondering if there is any framework or sophisticated way of doing the same with Spring MVC?

2 Answers

Chris Ramacciotti
seal-mask
STAFF
.a{fill-rule:evenodd;}techdegree
Chris Ramacciotti
Treehouse Guest Teacher

Can I interest you in a workshop to answer your question? This workshop covers unit testing of controllers, services, and DAOs. Just published today! :)

Unit Testing a Spring Application

https://teamtreehouse.com/library/unit-testing-a-spring-application

Karrtik Iyer
Karrtik Iyer
3,738 Points

Thanks Chris Ramacciotti , I shall go through the same and get back to you if I have any questions.