开发者

How to test a Web Service with Watin

I'm trying to write a test that invokes a web service and tests it's results.

[Test]
        public void should_display_correct_customer_when_DoCustomerSearch_is_invoked()
        {
            using (var browser = new IE("http://localhost:61245/WebServices/CustomerSearch.asmx?op=DoCustomerSearch"))
            {       
                browser.WaitForComplete();

                browser.TextField(Find.ByName("txtSearch")).TypeText("microsoft");
                browser.Button(Find.ByValue("Invoke")).Click();
                browser.Close();

                IE poppedUpBrowser = IE.AttachTo<IE>(Find.ByUrl("http://localhost:61245/WebServices/CustomerSearch.asmx/DoCustomerSearch"));

                poppedUpBrowser.WaitForComplete();
                Assert.IsTrue(poppedUpBrowser.ContainsText("Microsoft Corporation"));                
            } 
        }

When开发者_如何学JAVA I invoke the service through the browser, the results are displayed but when watin runs through the same test, the results page has a 500 server error.

Any help appreciated please.


Are you trying to test Web Service through WatiN?

There are better ways to do that: you should rather test your logic in unit / integration tests. Those tests will execute much faster than WatiN.

The HTTP 500 is returned by your web service - there is probably an exception being thrown from your code - check your logs or attach a debugger.


I agree with Jakub, using WatiN to test web services doesn't seem like a good idea. You should consume the web service using Visual Studio, which will create a class for you. You can call the web service via the generated class and check the result.

0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜