我应该依赖 WebTests 进行数据验证吗?
我有一套为 Web 服务创建的 Web 测试。我用它来测试更新 SQL 数据库的特定输入方法。 Web 服务没有办法检索数据,这不是它的目的,只是更新数据。我有一个验证器,用于验证 Web 服务为每个请求生成的响应 XML。一切都很好。
一位队友建议我添加数据验证,以便在初始响应验证器运行后检查数据库以查看数据,并将其与输入请求中的内容进行比较。我们有许多与我正在测试的 Web 服务分开的服务和库,我可以使用它们来获取数据并进行比较。问题是,当我运行 Web 测试时,即使请求成功,数据验证也总是失败。我尝试在响应验证和数据验证之间让线程休眠,但没有成功;它始终从响应验证之前获取数据。我可以设置一个断点,并直观地看到数据已在数据库中更新,有趣的是,当我使用断点在调试中单步执行它时,它确实验证成功。
在我深入探讨这个问题之前,我必须先问一下;这就是网络测试的目的吗?我是否应该能够以这种方式通过服务调用来验证数据,或者我是否对 Web 测试要求太多并且响应验证已经达到了我应该做的程度?
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?
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
这对测试要求不高,只需确保在为 WebService 调用生成 WebTestRequest 之后调用数据库测试即可。
因此在这种情况下,数据库检查与调用是分开的。
如果仍然存在问题,请发布您的网络测试代码。
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.