diff --git a/docs/contributing/debugging.md b/docs/contributing/debugging.md index 4885c26412f9..0ad2ea4b0c71 100644 --- a/docs/contributing/debugging.md +++ b/docs/contributing/debugging.md @@ -88,3 +88,7 @@ Execute tests as native executables: ``` The tracing data will be generated in the `build/native/agent-output` folder. + +## Debugging tests + +See [Debugging tests](running-tests.md#debugging-tests) for more information on debugging tests. diff --git a/docs/contributing/intellij-setup-and-troubleshooting.md b/docs/contributing/intellij-setup-and-troubleshooting.md index 4bc57ac18d70..b9b43c95e275 100644 --- a/docs/contributing/intellij-setup-and-troubleshooting.md +++ b/docs/contributing/intellij-setup-and-troubleshooting.md @@ -41,6 +41,10 @@ For example, to load the modules for the Spring Boot autoconfigure instrumentati Install the [Kotlin executable](https://kotlinlang.org/docs/tutorials/command-line.html) if you don't have it already. +## Debugging tests + +See [Debugging tests](running-tests.md#debugging-tests) for more information on debugging tests. + ## Troubleshooting Occasionally, Intellij gets confused, maybe due to the number of modules in this project, diff --git a/docs/contributing/running-tests.md b/docs/contributing/running-tests.md index 836a0f6d900b..59efbda591f0 100644 --- a/docs/contributing/running-tests.md +++ b/docs/contributing/running-tests.md @@ -38,6 +38,20 @@ To run these tests locally, add `-PtestLatestDeps=true` to your existing `gradle Executing `./gradlew :instrumentation::test --tests ` will run only the selected test. +### Debugging tests + +If you have trouble debugging tests in IntelliJ IDEA (because the classpath is not correct), +you can use remote debugging: + +1. Run the tests with the `--debug-jvm` flag. +2. Create a new remote debug configuration in IntelliJ IDEA. + +This example shows how to debug a single test: + +```shell +./gradlew :instrumentation:spring:spring-batch-3.0:javaagent:test --tests "io.opentelemetry.javaagent.instrumentation.spring.batch.v3_0.basic.JavaConfigBatchJobTest.shouldTraceTaskletJobStep" --debug-jvm +``` + ### How to prevent linting and formatting warnings from failing tests During local development, you may want to ignore lint warnings when running tests.