Skip to content

Docker for UTBot Java

Egor Vasilyev edited this page Dec 28, 2022 · 2 revisions

Reproducible environment

It's available to download docker image with the environment for UTBot. The environment is also used in the crucial CI scripts focused on building project and running tests.

The docker image pre-installed environment includes:

  1. Java 11
  2. Gradle 7.4.2
  3. Kotlin compiler 1.7.10

It's based on Ubuntu focal (20.04).

How to install Docker

Using reproducible environment requires Docker installed.

The detailed information of how to install Docker can be found on the official site.

How to run tests in docker container

Do the following steps to run tests in docker container:

  1. Pull docker image
docker pull unittestbot/java-env:java11-zulu-jdk-gradle7.4.2-kotlinc1.7.0
  1. Run docker container
# -v <utbot-repository-root>:/usr/utbot - mounts the host directory into the container directory
# -it - make the container look like a terminal connection session
# -w /usr/utbot - sets up working directory inside the container
docker run -it -v <utbot-repository-root>:/usr/utbot--name utbot-tests -w /usr/utbot unittestbot/java-env:java11-zulu-jdk-gradle7.4.2-kotlinc1.7.0
  1. Do whatever you want
  • Build UTBot and run tests:
gradle clean build --no-daemon
  • Build UTBot without running tests:
gradle clean build --no-daemon -x test
  • Run tests for utbot-framework project CustomerExamplesTest class:
gradle :utbot-framework:test --no-daemon --tests "org.utbot.examples.collections.CustomerExamplesTest"
  1. Exit container
exit

How to debug UTBot in docker container

Do the following steps to debug UTBot in docker container:

  1. Set up configuration for remote debug in IntelliJ IDEA

Run/Debug ConfigurationsAdd New Configuration → Choose Remote JVM Debug → Set up Configuration nameOk

  1. Pull docker image
docker pull unittestbot/java-env:java11-zulu-jdk-gradle7.4.2-kotlinc1.7.0
  1. Run docker container
# -v <utbot-repository-root>:/usr/utbot - mounts the host directory into the container directory
# -it - make the container look like a terminal connection session
# -w /usr/utbot - sets up working directory inside the container
# -p 5005:5005 - mounts the host port into the container port (debugging port)
docker run -it -p 5005:5005 -v <utbot-repository-root>:/usr/utbot --name utbot-debug -w /usr/utbot unittestbot/java-env:java11-zulu-jdk-gradle7.4.2-kotlinc1.7.0
  1. Set up gradle options for remote debug:
export GRADLE_OPTS=-agentlib:jdwp=transport=dt_socket,server=y,suspend=n,address=*:5005
  1. Start building and running tests
gradle clean build --no-daemon
  1. Attach in IntelliJ IDEA to the gradle process in the container

Set up breakpoints wherever you want → Run new Configuration in Debug mode

  1. Exit container
exit
Clone this wiki locally