Reputation: 12375
I have an ASP site with web services that access outside libraries. i.e. all of my web services are contained in the "App_Code" folder.
I would like to unit test these web services, but I need to be authenticated in order to access them.
Is there a way to unit test authenticated web services in an ASP web project?
I found this question that seems to be asking a similar question, but I thought there may have been some developments in 3 years.
I also found this project that tests code behinds, which is ALMOST what I need, but not quite.
Thanks in advance!
Upvotes: 1
Views: 553
Reputation: 3680
The answer posted at the question you referred to is the correct answer for this situation. Class libraries that are testable, called by your services are the way to go. Your webservice layer would be extremely thin then, and have almost no logic in of itself.
This way you get proper unit tests of the business logic in question.
Upvotes: 1
Reputation: 4886
If there are services outside of your control, you would generally either stub or hide them behind an interface and mock them. This is so that you can setup expectancies for your own internal framework/application testing.
If you want to ensure that your interaction with those services are working, you could then have integration tests that will call the "development" services for testing purposes.
Upvotes: 2