views:

26

answers:

1

I have a suite of web tests created for a web service. I use it for testing a particular input method that updates a SQL Database. The web service doesn't have a way to retrieve the data, that's not its purpose, only to update it. I have a validator that validates the response XML that the web service generates for each request. All that works fine.

It was suggested by a teammate that I add data validation so that I check the database to see the data after the initial response validator runs and compare it with what was in the input request. We have a number of services and libraries that are separate from the web service I'm testing that I can use to get the data and compare it. The problem is that when I run the web test the data validation always fails even when the request succeeds. I've tried putting the thread to sleep between the response validation and the data validation but to no avail; It always gets the data from before the response validation. I can set a break point and visually see that the data has been updated in the DB, funny thing is when I step through it in debug with the breakpoint it does validate successfully.

Before I get too much more into this issue I have to ask; Is this the purpose of web tests? Should I be able to validate data through service calls in this manner or am I asking too much of a web test and the response validation is as far as I should go?

+1  A: 

That is not asking too much of the test, just make sure the database test gets called after you yield the WebTestRequest for the WebService call.

So in that case, the database check is separate from the call.

Post code for your webtest if there are still issues.

Nat
Thanks Nat. I found out what the issue was as well. I was getting the data in the DataValidator instantiation; even though that occured after the web test yielded its results it was old data. Once I move the code to get the data into the actual Validate method it worked.
Alexander Kahoun