# ESSingleNodeTestCase - Java 11 - Does not start Elastic

**URL:** <https://discuss.elastic.co/t/essinglenodetestcase-java-11-does-not-start-elastic/282279>\
**Category:** Elasticsearch\
**Created:** [August 23, 2021, 10:09pm UTC](https://discuss.elastic.co/t/essinglenodetestcase-java-11-does-not-start-elastic/282279 "2021-08-23T22:09:53Z")\
**Posts on this page:** 2\
**Page:** 1

<div class="post-metadata">

**Author:** ![Liyaqat\_M](https://sea2.discourse-cdn.com/elastic/user_avatar/discuss.elastic.co/liyaqat_m/32/93599_2.png) [@Liyaqat\_M](https://discuss.elastic.co/u/Liyaqat_M)\
**Post date:** [August 23, 2021, 10:09pm UTC](https://discuss.elastic.co/t/essinglenodetestcase-java-11-does-not-start-elastic/282279/1 "2021-08-23T22:09:53Z")

</div>

Hi,

I am trying to test the messages that I would post to our Elastic Search server and decided to use: ESSingleNodeTestCase.

After sorting out the dependencies I was able to compile and start the test.

As far as I understand from extending the ESSingleNodeTestCase in my test it should automatically call the setup() ?

When I try to manually call it I get:

> No context information for thread: Thread[id=16, name=Test worker, state=RUNNABLE, group=main]. Is this thread running under a class com.carrotsearch.randomizedtesting.RandomizedRunner runner context? Add @RunWith(class com.carrotsearch.randomizedtesting.RandomizedRunner.class) to your test class. Make sure your code accesses random contexts within @BeforeClass and @AfterClass boundary (for example, static test class initializers are not permitted to access random contexts).  
> java.lang.IllegalStateException: No context information for thread: Thread[id=16, name=Test worker, state=RUNNABLE, group=main]. Is this thread running under a class com.carrotsearch.randomizedtesting.RandomizedRunner runner context? Add @RunWith(class com.carrotsearch.randomizedtesting.RandomizedRunner.class) to your test class. Make sure your code accesses random contexts within @BeforeClass and @AfterClass boundary (for example, static test class initializers are not permitted to access random contexts).  
> at com.carrotsearch.randomizedtesting.RandomizedContext.context(RandomizedContext.java:249)

My sample test looks like this:

```auto
import com.carrotsearch.randomizedtesting.RandomizedRunner;
import org.elasticsearch.test.ESSingleNodeTestCase;
import org.junit.Before;

import org.junit.jupiter.api.Test;
import org.junit.runner.RunWith;

@RunWith(RandomizedRunner.class)
public class ElasticSearchTest extends ESSingleNodeTestCase {

    @Before
    public void setupNew() throws Exception {
        System.out.println("hello");
    }

    @Test
    void testElastic () throws Exception{
        setUpClass();
        setUp();
        assertEquals("1", "1");
    }
}

```

I tried to use @BeforeClass and call setup() but it does not even run. Please help. Thanks

---

<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:** [September 20, 2021, 10:10pm UTC](https://discuss.elastic.co/t/essinglenodetestcase-java-11-does-not-start-elastic/282279/2 "2021-09-20T22:10:17Z")

</div>

This topic was automatically closed 28 days after the last reply. New replies are no longer allowed.
