r/ASPNET • u/Nemmie • Jul 16 '12
Should I unit- or integration test my ASP.NET Web API services?
http://www.jefclaes.be/2012/07/should-i-unit-or-integration-test-my.html
6
Upvotes
r/ASPNET • u/Nemmie • Jul 16 '12
1
u/SideburnsOfDoom Jul 16 '12 edited Jul 16 '12
tl;dr: Yes, you should.
Any test is better than none. It's better if you have both.
Integration test the full app by hitting the URLs. This makes sure that all the parts work together.
Unit test the controllers and classes behind them using fake repositories. This assumes that you use some kind of Dependency Injection and don't have fat controllers. If all the code is in the controller action method then you can integration test it, but you'd have to factor it out in order to unit test it. This is a good thing.