# Debugging unit tests in elasticsearch

**URL:** <https://discuss.elastic.co/t/debugging-unit-tests-in-elasticsearch/50634>\
**Category:** Elasticsearch\
**Created:** [May 21, 2016, 10:30pm UTC](https://discuss.elastic.co/t/debugging-unit-tests-in-elasticsearch/50634 "2016-05-21T22:30:02Z")\
**Posts on this page:** 3\
**Page:** 1

<div class="post-metadata">

**Author:** ![rbellamy](https://sea2.discourse-cdn.com/elastic/user_avatar/discuss.elastic.co/rbellamy/32/9534_2.png) [@rbellamy](https://discuss.elastic.co/u/rbellamy)\
**Post date:** [May 21, 2016, 10:30pm UTC](https://discuss.elastic.co/t/debugging-unit-tests-in-elasticsearch/50634/1 "2016-05-21T22:30:02Z")

</div>

I'm interested in attaching a debugger to the unit tests in Elasticsearch. In the TESTING document, it mentions that I can attach a debugger to the running version of Elasticsearch launched via Gradle (e.g. `gradle run --debug-jvm`), but there's no mention of a method for launching the unit tests in a debugger.

When reading the [Gradle User Guide](https://docs.gradle.org/current/userguide/userguide_single.html), the guidance is to pass a JVM switch to the test harness indicating that you want to attach a debugger (e.g. `gradle test -Dtest.debug`). I've tried that, and several other incantations, given that the tests in Elasticsearch seem to use a nomenclature that's a bit different than the Gradle norm (e.g. `gradle :core:test`).

Specifically, I'd like to attach the debugger to a single test, or test method:

```auto
gradle :core:test -Dtests.seed=B5E933798D9BAEDA \
  -Dtests.class=org.elasticsearch.deps.joda.SimpleJodaTests \
  -Dtests.logger.level=WARN \
  -Dtests.security.manager=true \
  -Dtests.locale=ar-LY \
  -Dtests.timezone=Europe/Sarajevo
  -D<WHAT GOES HERE???>.debug

```

I'm not very familiar with Gradle, so I need some guidance on how to launch a unit test, and then attach a debugger to that test? Maybe my challenge is that the unit tests are actually being launched via the Ant JUnit test runner?

---

<div class="post-metadata">

**Author:** ![system](https://us1.discourse-cdn.com/elastic/original/3X/1/a/1ac57faf039f6b580b3f104ef42a2a89e41014de.png) [@system](https://discuss.elastic.co/u/system)\
**Post date:** [July 5, 2017, 10:49pm UTC](https://discuss.elastic.co/t/debugging-unit-tests-in-elasticsearch/50634/2 "2017-07-05T22:49:57Z")

</div>



---

<div class="post-metadata">

**Author:** ![nyuriks](https://sea2.discourse-cdn.com/elastic/user_avatar/discuss.elastic.co/nyuriks/32/26171_2.png) [@nyuriks](https://discuss.elastic.co/u/nyuriks)\
**Post date:** [January 9, 2019, 4:48pm UTC](https://discuss.elastic.co/t/debugging-unit-tests-in-elasticsearch/50634/3 "2019-01-09T16:48:22Z")

</div>

@rbellamy I had the same issue, and luckily @ikakavas gave this magic parameter:

```auto
-Dtests.jvm.argline=-agentlib:jdwp=transport=dt_socket,server=y,suspend=y,address=8000

```
