Info | ||
---|---|---|
| ||
This page is a work in progress. This info box will be removed once complete. |
Postgres Repositories Unit tests
Testing Structure
The tests uses the configuration file opensrp-core/src/test/resources/test-applicationContext-opensrp.xml.
This file unlike the runtime loads both Postgres and CouchDb beans, this will to allow the existing unit tests that used Couchdb continue to work without any changes. The CouchDb beans are annotated with the annotation @Primary which means that they are the used even if there are other beans implementing an interface.
So the tests(unit and integration) thats are implicitly for postgres the units tests qualify the bean by the @Qualifier so that they specify explicitly the bean to be injected i.e in this this case Postgres bean.
Postgres Repositories Unit Tests
Units tests have been defined that unit test the Postgres repository package org.opensrp.repository.postgres. The repositories unit tests are in the package org.opensrp.repository.postgres
The unit tests use Junit for unit testing and test for various scenarios for each method in the respective repository class being tested. Each of the test extend the class org.opensrp.repository.postgres.BaseRepositoryTest. This class defines tow methods
...
Services Integration Tests
Integration tests were written for services. The tests concentrate on methods with some business logic or have pre or post processing before calling the repositories.
The services extends org.opensrp.repository.postgres.BaseRepositoryTest
so that they are also able to easily apply one or more scripts to populate seed before the tests commence.
With the repositories unit tests and units integration tests regression errors are easily reported early.