| Summary: | Networked code proves difficult to test thoroughly because test suites work best as standalone processes unreliant on other servers. In this article, Nelson Minar describes two techniques for unit testing network code. First, he proposes that you design your code such that as much logic as possible works independently from the network. Second, he suggests using Java's protocol handler classes to simulate network connections without actually using the network. By employing these principles, you'll produce easily tested network software. This article includes sample code for a Java protocol handler, as well as the PrintRSS demo program and a test suite for PrintRSS that demonstrates testing concepts. (1,750 words; July 19, 2002)
|