Versions Compared

Key

  • This line was added.
  • This line was removed.
  • Formatting was changed.

...

  • JUnit 4
  • System Rules – powerful set of JUnit 4 Rules
  • AssertJ – richer than JUnit 4 Assert and includes better support for expected exceptions
  • Awaitility – useful for awaiting asynchronous conditions
  • Mockito – preferred over all other mocking libraries
  • JUnitParams – provides test method parameterization
  • Catch-Exception – better support for expected exceptions especially with complex nesting of exceptions or exceptions with unusual APIs
  • PowerMock – use this as a last resort – refactoring code to facilitate better testing is preferred

...

  • Custom JUnit 4 Rules and testing frameworks

...

  • geode-junit JUnit 4 Rules:
    • ExecutorServiceRule – provides ExecutorService for concurrent testing
    • ExpectedTimeoutRule – verifies that an API times out and potentially throws TimeoutException
    • JarFileRule – creates a Jar file in an internal TemporaryFolder containing a dynamically generated class
    • RepeatRule – repeatedly executes a test
    • RequiresGeodeHome – asserts precondition that GEODE_HOME system property is specified
    • RestoreLocaleRule – restores JVM to original Locale
    • RestoreTCCLRule – restores Thread Context Class Loader
    • RetryRule – retries a test until it passes or exceeds specified number of retries
    • TemporaryFileRule – destroys specified files or directories that aren't created in a TemporaryFolder
    • UseJacksonForJsonPathRule – specifies that JsonPath should use Jackson instead of its default JSON library
    • GfshRule – allows use of Gfsh script string to fork a JVM process in an IntegrationTest
  • geode-junit JUnit 4 Rules that extend commonly used JUnit 4 Rules:
    • SerializableTemporaryFolder – allows a TemporaryFolder to be shared across multiple JVMs in a DistributedTest
    • SerializableTestName – allows a TestName to be shared across multiple JVMs in a DistributedTest
  • geode-core (under test) old TestCase classes for DistributedTest:
    • DistributedTestCase – base class for pre-existing distributed tests
    • CacheTestCase – base class for pre-existing distributed tests with APIs for getCache
  • geode-core (under test) API classes for DistributedTest:
    • AsyncInvocation – performs asynchronous invocations in multiple JVMs with Future API
    • Disconnect – disconnects JVMs from Geode cluster
    • DistributedTestUtils – misc utility APIs that don't fit into any of the other DistributedTest API classes
    • DUnitBlackboard – provides a blackboard (distributed map) that can be used in multiple JVMs
    • IgnoredException – specifies Exception string that will be ignored during suspect string grep which occurs in tearDown of DistributedTests
    • Invoke – APIs to invoke SerializableRunnables and SerializableCallables in multiple JVMs
    • NetworkUtils – networking utility APIs to get IP or host name
    • ThreadUtils – utility APIs to dumpt thread stacks
    • VM – the API representation of a remote JVM which is fetched from Host class
  • geode-core (under test) JUnit 4 Rules for DistributedTest:
  • DistributedRule – use this instead of extending DistributedTestCase
  • CacheRule – use this with DistributedRule instead of extending CacheTestCase
  • ClusterStartupRule – use this by itself for Gfsh and Management tests
  • DistributedDisconnectRule – disconnects all JVMs from Geode cluster (similar to APIs in Disconnect class)
  • DistributedRestoreSystemProperites – version of RestoreSystemProperites which executes in all JVMs
  • DistributedUseJacksonForJson – version of UseJacksonForJsonPathRule which executes in all JVMs
  • SharedCountersRule – provides distributed counters and APIs which can be used in all JVMs
  • SharedErrorCollector – version of ErrorCollector which can be used in all JVMs(including DUnit) that are part of Geode

Always write unit tests for new functionality and always ensure that all unit tests pass before submitting a pull request. Try to make sure new functionality is covered by unit tests, whether or not there are also integration tests as well.

...