You might want to have a look at JPetStore. Although it's Java, you might get some ideas.
JPetStore uses the DAO and Mapping layers and achieves a 92% coverage (really only exceptions aren't tested by choice/laziness). ;-) Also consider organizing your tests into Unit, Persistence and Integration. Unit Tests are self contained, very fast to run and don't require any external resources like connections to a database or files. To run your entire Unit Test project should take less than one minute (we routinely are able to run over 1000 unit tests in less than a minute). Use a Mock framework to mock the DAOs and Service layer of your application. Your classes should have two constructors: One should be parameterless and instantiate the service or DAO. The other should take the Service or DAO as a parameter -- thus enabling you to pass in a mock. Persistence Tests are allowed to access a test instance of your database. This is how you test your SQL and Stored Procs. Hence, this is also how you test your iBATIS SQL Maps. The persistence suite should drop and rebuild the database (DDL), as well as load up the test data. These tests may take longer than one minute, but should still run reasonably fast -- still shoot for one minute, but a few minutes is acceptable. Integration Tests are allowed to access test instances of dependent servers, files, web services, databases or test instances of other applications. These tests may take a lot longer depending on the dependencies, especially one's you can't control. Sometimes if they take too long, we'll only run them as part of the CI build, not necessarily on every developer's workstation. So check out JPetStore, and you might even want to pick up a copy of iBATIS in Action, as it does explain some of this (although in a Java context). Cheers, Clitnon Clinton On 2/16/07, Brian Kierstead <[EMAIL PROTECTED]> wrote:
Hello, We are currently implementing unit testing on our team and trying to figure out how to do it. We use ibatis, both the dao and mapper, and layers similar to the npetshop project. We want to test our persistence layer, but we're stuck on how to do it since the dao is instantiated in the service layer. What are others doing? We've talked about replicating the entire service layer, along with the config files for ibatis, but that seems like a lot do. Thanks! B

