You can attach a debugger to the JVM to step through your Groovy scripts, inspect variables etc.
The key steps involved are:
- Enable the JVM debugger, listening on a local port
- Start Imposter
- Connect to the debug port
Enable the JVM debugger with the following environment variable:
JAVA_TOOL_OPTIONS="-agentlib:jdwp=transport=dt_socket,server=y,suspend=n,address=8000"
Note Here we have set the debug port to 8000.
When running in Docker, make sure to expose the debug port.
For example:
docker run --rm -it -p8080:8080 -p8000:8000 -v $PWD:/opt/imposter/config outofcoffee/imposterIn this example, port 8000 is exposed along with the regular port, 8080.
When using the CLI, pass the --debug-mode flag.
For example:
imposter up --debug-modeIn this example, port 8000 is exposed along with the regular port, 8080.
This section explains how to connect your IDE's debugger to the debug port.
In IntelliJ, create a simple project pointing to the directory containing your script file.
In the following steps, we will add a new run configuration, start the mock and attach the debugger.
- Add a 'Remote JVM Debug' run configuration:

- Set the
Portto the same value as the debug configuration. - Start Imposter and wait for the server to be ready.
- In IntelliJ start the run configuration in Debug mode, which will connect the debugger to the Imposter JVM.
Set breakpoints in the script file as normal. When your script is invoked in Imposter, the debugger will pause on breakpoints and you can evaluate variables in scope.
