I'd like for more of my colleagues to write unit tests. My motives are selfish. Unit tests help me figure out how methods of the unit are supposed to work. Unit tests are documentation too. And if a unit is testable, that makes it pretty good code. I believe one reason that some of my fellows don't write unit tests is because they're not quite sure how the mock object thing fits in. I'll explain.
This paper gives a complete description of code coverage analysis (test Applying Mock objects effectively is a key factor when performing Test Driven Development (TDD). In this article I'll introduce the basics of using JMock, a Mock object framework, in conjunction with Test-Driven Development. To illustrate the technique I will work through a case study, the creation of a cache component by means of test-first development with JMock.
Writing unit tests for code that accesses the database is a recurring challenge for Java developers. This post will describe a technique we’ve used successfully on a number of database-intensive projects: using HSQLDB as an in-memory database so that the database access code can be thoroughly tested without dependencies on external resources.
This article gives a short overview of unit testing with JUnit 4.x and Easymock within Eclipse. The creation of a test using the the new annotations in JUnit 4 are explained and the creation of JUnit 4 test suites. Test suites groups several tests. EasyMock is then used to emulate objects to enable Junit to test each object in isolation. You should be able to run tests with JUnit from Eclipse after reading this article.
In this document you will learn about creating testing classes for your project. One of the hardest tasks when using a new tool is learning how to integrate it into your regular build lifecycle. Hopefully this tutorial will help you in creating new test classes, maintain your existing test classes, and take advantage of advanced features in the csUnit API.