Software Testing¶
Java and Python based test frameworks and libraries that support software integration testing with CrateDB.
Java JUnit¶
The popular JUnit framework is supported by CrateDB Java Testing Classes, provided per io.crate:crate-testing package available on Maven Central. Its source code is maintained within the crate-java-testing repository on GitHub.
The package includes CrateTestServer
and CrateTestCluster
classes for use
as JUnit external resources. Both classes download and start CrateDB before
test execution, and stop CrateDB afterwards.
This example project includes a corresponding setup that you can use right away to get started.
Python pytest¶
The popular pytest framework makes it easy to write small tests, but it also supports complex functional testing for applications and libraries. The pytest-cratedb package manages CrateDB instances for running integration tests against them.
It is based on cr8 for the heavy lifting, and additionally provides
the crate
, crate_execute
, and crate_cursor
pytest fixtures for
developer convenience.
Python unittest¶
cr8, a collection of tools for CrateDB developers, provides primitive elements to manage CrateDB single-node and multi-node instances through its run-crate subsystem, that can be used to create test layers for Python’s built-in unittest framework.
Testcontainers¶
Testcontainers is an open source framework for providing throwaway, lightweight instances of databases, message brokers, web browsers, or just about anything that can run in a Docker container.
CrateDB provides Testcontainers implementations for both Java and Python.