CrateTestServer and CrateTestCluster classes for use as JUnit external
resources.
Both classes download and start CrateDB before test execution and stop CrateDB afterwards.
JAR files are hosted on Maven Central.
...
<dependencies>
...
<dependency>
<groupId>io.crate</groupId>
<artifactId>crate-testing</artifactId>
<version>...</version>
</dependency>
</dependencies>
...You can integrate with Gradle like so:
repositories {
...
mavenCentral()
}
dependencies {
compile 'io.crate:crate-testing:...'
...
}The CrateTestCluster class is io.crate.testing.CrateTestCluster and
extends org.junit.rules.ExternalResources.
Once it's initalized as a JUnit ClassRule, CrateTestCluster will start
CrateDB at the beginning of the test run. If CrateDB is not already downloaded,
it will be downloaded and extracted.
To start CrateTestCluster, use static factory methods fromURL,
fromFile, fromSysProperties or fromVersion.
Example usage in a Java test:
@ClassRule
public static final CrateTestCluster TEST_CLUSTER =
CrateTestCluster.fromVersion("3.3.2")
.clusterName("with-builder")
.numberOfNodes(3)
.build();When using the fromSysProperties static factory method, either the
crate.testing.from_version or crate.testing.from_url system property
must be set. If both system properties are provided, the
crate.testing.from_version property is used.
This project is primarily maintained by Crate.io, but we welcome community contributions!
See the developer docs and the contribution docs for more information.
Looking for more help?
- Check out our support channels