Chapter 12: Implementing a Web Client

In this last chapter, we will start the implementation of a Web client. In its final form, the Web client will allow users to search for recording information stored in the database, modify the various attributes of a recording, and delete questionable reviews.

This chapter shows the implementation of the Search page, which demonstrates many of the issues you might encounter when developing a Web client using Test-Driven Development.

Testing User Interfaces

Testing user interface code challenges you in a number of ways differently than testing situations we have described previously.

  • Functional testing The easiest way to test a Web application is to open a Web browser, type in the URL, and verify that the Web page works as expected. This process can be automated with tools that simulate user inputs and then verify that the page returned has the expected values. The Microsoft Application Center Test tool is one example. There is nothing wrong with these types of tests; the issue with regard to TDD is that we need a way to incrementally build the system with programmer tests.

  • Programmer tests in ASP.NET What we want to do is instantiate a page object inside an NUnit test and then test it as we would any other object. It turns out that you can instantiate the page objects in the test, but they aren t instantiated the same way as is done by HttpRuntime . For example, none of the controls is initialized when you instantiate the page in the test. You can manually instantiate them, but you have to ask yourself what you are testing at this point. You could decide to host the HttpRuntime , which is possible, but has it own troubles. (For a detailed discussion of how to do this, along with sample code, see .) Because we can t do what we want to do directly, we ll build as much functionality as possible outside of ASP.NET instead in order to be able to write programmer tests.

By the end of this chapter, you should have a good understanding of the issues associated with writing programmer tests for Web-based user interfaces and how some of these issues are mitigated using the testing strategies presented here.

Test-Driven Development in Microsoft .NET
Test-Driven Development in Microsoft .NET (Microsoft Professional)
ISBN: 0735619484
EAN: 2147483647
Year: 2004
Pages: 85

Similar book on Amazon © 2008-2017.
If you may any questions please contact us: