There are quite a few examples of good mocking in both unit tests and
integration tests, with the majority being in unit tests. An easy way to
find many of these tests in Geode is to grep for uses of MockitoRule with
STRICT_STUBS.

Also, remember that if the test touches disk or network then it's an
integration test and should be in src/integrationTest instead of src/test
in the module.

We really should move away from the old Fakes class that is in geode-junit.
It's hard-wired to fake everything in Geode (Cache and DistributedSystem,
top-to-bottom) and mocks implementation classes instead of pushing us
towards using and mocking interfaces. If you find yourself modifying a unit
test that uses Fakes, please consider updating that test to not use it.

A good unit test should just directly use our preferred testing libraries
of Mockito and AssertJ, be self-contained other than using simple JUnit
Rules. Unit tests should perform validation via the APIs it exposes to
other classes where possible or via package-private methods annotated
with @VisibleForTesting if needed. The latter helps quite a bit to get
existing legacy code under test.

Cheers,
Kirk

Reply via email to