TBD: include pointers to "good" unit tests in the project
Geode is tested with a combination of tests written with JUnit , DUnit (distributed unit) and regression testsand DUnit. JUnit tests are written as with any other project while DUnit tests use a multi-JVM environment (see Distributed Unit Tests DistributedTest).
JUnit tests are divided into two main categories: UnitTest and IntegrationTest.
...
- Should use JUnit 4 syntax
- File name ends with *Test
- Should use Category annotation of type UnitTestbe part of the test source set folder (<geode-module-dir>/test/java)
- Should complete in milliseconds
- Should generally test a single class
- Typically uses white-box testing, uses Mocks/Fakes and helps guarantee internal quality (quality of code and class design)
- Follows "A Set of Unit Testing Rules" by Michael Feathers
- A UnitTest should not do any of the following:
- communicate with a database
- communicate across the network
- access the file system
- prevent the running of other unit tests in parallel
- require anything special in the environment (such as editing config files or running an external process)
- A UnitTest should not do any of the following:
...
- Should use JUnit 4 syntax
- File name ends with *IntegrationTest
- Should use Category annotation of type IntegrationTestbe part of the integrationTest source set folder (<geode-module-dir>/integrationTest/java)
- May take longer than a UnitTest but should generally complete in seconds
- May test a single class or any combination of classes including end-to-end testing of Geode
- Typically uses black-box testing but may include some white-box testing and helps guarantee external quality (feature delivers value to User)
- An IntegrationTest may do any of the following:
- communicate across the network
- access the file system
- require anything special in the environment (such as editing config files or running an external process)
- Good examples in Geode:
- RegionExpirationIntegrationTest
DUnit tests are a special type of JUnit test involving multiple JVMs. This supports writing tests for a Geode cluster.
3. DistributedTest: a test involving multiple members of a distributed system.
- Should use JUnit 4 syntax
- File name ends with *DistributedTest or *DUnitTest
- Should use Category annotation DistributedTestbe part of the distributedTest source set folder (<geode-module-dir>/distributedTest/java)
- Should generally complete in seconds
- May test interactions between multiple JVMs in a Geode cluster or via networking or via file system
- Typically uses black-box testing but may include some white-box testing and helps guarantee external quality (feature delivers value to User)
- A DistributedTest may do any of the following:
- communicate across the network
- access the file system
- require anything special in the environment (such as editing config files or running an external process)
...