I’m trying to migrate to CircleCI. The project is built using kotlin/java and gradle. It has a bunch of unit tests and some cucumber tests, these tests can be run using the ‘gradle test’ command.
An instance of the application is required to be run in the background for the cucumber tests to pass. I’ve tried to do this by running the application in the background and then running the tests. However, it looks like the tests get executed and fail before the background process has a chance to start. Any tips on how to get around this?
version: 2
jobs:
build:
docker:
# specify the version you desire here
- image: circleci/openjdk:8-jdk
working_directory: ~/repo
environment:
# Customize the JVM maximum heap limit
JVM_OPTS: -Xmx3200m
TERM: dumb
steps:
- checkout
# Download and cache dependencies
- restore_cache:
keys:
- v1-dependencies-{{ checksum "build.gradle" }}
# fallback to using the latest cache if no exact match is found
- v1-dependencies-
- run: gradle dependencies
- save_cache:
paths:
- ~/.gradle
key: v1-dependencies-{{ checksum "build.gradle" }}
- run: gradle clean assemble jar
- run: java -jar build/libs/definitions-catalogue-1.0.jar &
- run:
name: Run the application
command: gradle run
background: true
# run tests
- run: gradle test
Edit: I’ve tried to make the test re try the connection if it fails the first time (using Thread.Sleep()). However this appears to be ignored when the test is running.