Corda5 Integration Testing
with Gradle, JUnit5, Corda5-Testutils and Corda5-CLI-Action
This is a quick HOWTO for Corda5 integration testing, both local and CI with GitHub Actions. You can find the working code in this CSDE fork, specifically in this PR.
Note: seems corda-runtime-os release-5.0.0 disappeared from GitHub. Our sample is based on CSDE release/corda-5–0, only updated to use Corda 5.0.1 and Java 17.
Prerequisites
Same as CSDE:
- Azul Zulu JDK 17
- Git ~v2.24.1
- Docker Engine ~v20.X.Y or Docker Desktop ~v3.5.X
- Corda CLI, see Installing the Corda CLI
Gradle Setup
The corda5-testutils dependency includes a JUnit5 extension
for starting the Combined Worker and an API for calling flows etc.
Let’s add the dependency version to gradle.properties:
# Corda 5 Test Utils
corda5TestutilsVersion=1.2.1
Now into workflows/build.gradle, we add separate configuration, sourceSets etc. for integration tests:
And the corda5-testutils dependency for launching Corda’s Combined Worker:
Create a Test
Here’s how our Integration Test looks like:
Test with Gradle
We have to call integration tests explicitly:
./gradlew build integrationTest
Test with GitHub Actions
The corda5-cli-action will download, install and cache the Corda5 CLI, so the Gradle build will just work. The workflow file contains the following:
You can see the workflow runs in the repository’s actions area.
Build Successful
All done. You can find the code in CSDE-cordapp-integration-testing