Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

how to debug tests #12224

Open
wants to merge 1 commit into
base: main
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 4 additions & 0 deletions docs/contributing/debugging.md
Original file line number Diff line number Diff line change
Expand Up @@ -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.
4 changes: 4 additions & 0 deletions docs/contributing/intellij-setup-and-troubleshooting.md
Original file line number Diff line number Diff line change
Expand Up @@ -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,
Expand Down
14 changes: 14 additions & 0 deletions docs/contributing/running-tests.md
Original file line number Diff line number Diff line change
Expand Up @@ -38,6 +38,20 @@ To run these tests locally, add `-PtestLatestDeps=true` to your existing `gradle

Executing `./gradlew :instrumentation:<INSTRUMENTATION_NAME>:test --tests <GROOVY TEST FILE NAME>` 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.
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

[minor] maybe link to gradle documentation about this.

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

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.
Expand Down
Loading