# How to use ESIntegTestCase in elasticsearch 6.6.1

**URL:** <https://discuss.elastic.co/t/how-to-use-esintegtestcase-in-elasticsearch-6-6-1/174646>\
**Category:** Elasticsearch\
**Created:** [March 30, 2019, 4:57pm UTC](https://discuss.elastic.co/t/how-to-use-esintegtestcase-in-elasticsearch-6-6-1/174646 "2019-03-30T16:57:51Z")\
**Posts on this page:** 10\
**Page:** 1

<div class="post-metadata">

**Author:** ![EliuFlorez](https://sea2.discourse-cdn.com/elastic/user_avatar/discuss.elastic.co/eliuflorez/32/40884_2.png) [@EliuFlorez](https://discuss.elastic.co/u/EliuFlorez)\
**Post date:** [March 30, 2019, 4:57pm UTC](https://discuss.elastic.co/t/how-to-use-esintegtestcase-in-elasticsearch-6-6-1/174646/1 "2019-03-30T16:57:51Z")

</div>

Hi,  
When I run the source code:

```auto
import org.elasticsearch.common.settings.Settings;
import org.elasticsearch.plugins.Plugin;
import org.elasticsearch.test.ESIntegTestCase;
import org.elasticsearch.test.ESIntegTestCase.ClusterScope;
import org.elasticsearch.test.ESIntegTestCase.Scope;

import java.util.Collection;
import java.util.Collections;

import org.elasticsearch.cluster.metadata.IndexMetaData;

@ClusterScope(scope = Scope.SUITE, numDataNodes = 1, numClientNodes = 0, transportClientRatio = 0, supportsDedicatedMasters = false)
public class AbstractSearchScriptTestCase extends ESIntegTestCase {

	@Override
	protected Settings nodeSettings(int nodeOrdinal) {
		return Settings.builder().put(super.nodeSettings(nodeOrdinal))
			.put("network.host", "localhost")
			.put("http.port", "9200")
			.build();
	}
	
    @Override
    public Settings indexSettings() {
        return Settings.builder()
	        .put(IndexMetaData.SETTING_NUMBER_OF_SHARDS, 1)
	        .put(IndexMetaData.SETTING_NUMBER_OF_REPLICAS, 0)
	        .build();
    }
    
    @Override
    protected Collection<Class<? extends Plugin>> nodePlugins() {
    	return Collections.singletonList(RecurringPlugin.class);
    }
}

```

I get an error:

```auto
Exception in thread "Thread-1" java.lang.NoClassDefFoundError: Could not initialize class org.elasticsearch.test.ESTestCase
	at java.lang.Thread.run(Unknown Source)
	Suppressed: java.lang.IllegalStateException: No context information for thread: Thread[id=13, name=Thread-1, state=RUNNABLE, group=TGRP-RecurringElasticsearchTest]. 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)
		at com.carrotsearch.randomizedtesting.RandomizedContext.current(RandomizedContext.java:134)
		at com.carrotsearch.randomizedtesting.RandomizedRunner.augmentStackTrace(RandomizedRunner.java:1885)
		at com.carrotsearch.randomizedtesting.RunnerThreadGroup.uncaughtException(RunnerThreadGroup.java:20)
		at java.lang.Thread.dispatchUncaughtException(Unknown Source)

```

How to fix this error?

---

<div class="post-metadata">

**Author:** ![jasontedor](https://sea2.discourse-cdn.com/elastic/user_avatar/discuss.elastic.co/jasontedor/32/66992_2.png) [@jasontedor](https://discuss.elastic.co/u/jasontedor)\
**Post date:** [March 30, 2019, 9:32pm UTC](https://discuss.elastic.co/t/how-to-use-esintegtestcase-in-elasticsearch-6-6-1/174646/2 "2019-03-30T21:32:50Z")

</div>

Did you try what the error message says?

```auto
Add @RunWith(class com.carrotsearch.randomizedtesting.RandomizedRunner.class) to your test class.

```

We use randomization within our test framework.

---

<div class="post-metadata">

**Author:** ![EliuFlorez](https://sea2.discourse-cdn.com/elastic/user_avatar/discuss.elastic.co/eliuflorez/32/40884_2.png) [@EliuFlorez](https://discuss.elastic.co/u/EliuFlorez)\
**Post date:** [March 31, 2019, 2:25pm UTC](https://discuss.elastic.co/t/how-to-use-esintegtestcase-in-elasticsearch-6-6-1/174646/3 "2019-03-31T14:25:28Z")

</div>

Hello, if I try it with simple test and with RunWith and it keeps presenting the same error.

Simple test

```auto
import org.elasticsearch.test.ESIntegTestCase;
import org.junit.Test;

public class RecurringElasticsearchTest extends ESIntegTestCase {

	@Test
    public void test() throws Exception {
		System.out.println("Hello");
    }
	
}

```

And RunWith

```auto
import org.elasticsearch.common.settings.Settings;
import org.elasticsearch.test.ESIntegTestCase;
import org.elasticsearch.test.ESIntegTestCase.ClusterScope;
import org.elasticsearch.test.ESIntegTestCase.Scope;
import org.elasticsearch.test.junit.annotations.TestLogging;
import org.junit.Assert;
import org.junit.Before;
import org.junit.Test;
import org.junit.runner.RunWith;

@TestLogging("_root:DEBUG")
@ClusterScope(scope = Scope.SUITE)
@RunWith(com.carrotsearch.randomizedtesting.RandomizedRunner.class)
public class RecurringIntTest extends ESIntegTestCase {

	@Override
	protected Settings nodeSettings(int nodeOrdinal) {
		return Settings.builder().put(super.nodeSettings(nodeOrdinal)).build();
	}

	@Before
	public void setUp() throws Exception {
		super.setUp();
	}
	
	@Test
	public void testRecurringScript() throws Exception {
		Assert.assertTrue(true);
	}
}

```

What will happen?

---

<div class="post-metadata">

**Author:** ![jasontedor](https://sea2.discourse-cdn.com/elastic/user_avatar/discuss.elastic.co/jasontedor/32/66992_2.png) [@jasontedor](https://discuss.elastic.co/u/jasontedor)\
**Post date:** [March 31, 2019, 2:32pm UTC](https://discuss.elastic.co/t/how-to-use-esintegtestcase-in-elasticsearch-6-6-1/174646/4 "2019-03-31T14:32:12Z")

</div>

Sorry, but you have not provided enough information for us to debug this. Would you please provide a _full_ reproduction. Code is not enough, since we don't know how you're invoking the tests, what runner you are using, etc.

---

<div class="post-metadata">

**Author:** ![EliuFlorez](https://sea2.discourse-cdn.com/elastic/user_avatar/discuss.elastic.co/eliuflorez/32/40884_2.png) [@EliuFlorez](https://discuss.elastic.co/u/EliuFlorez)\
**Post date:** [April 1, 2019, 8:35pm UTC](https://discuss.elastic.co/t/how-to-use-esintegtestcase-in-elasticsearch-6-6-1/174646/5 "2019-04-01T20:35:43Z")

</div>

Hello, I already corrected that error but now I present this error  
and the error that indicates to me is a blank line nothing more:

```auto
* What went wrong:
Execution failed for task ':forbiddenPatterns'.
> Found invalid patterns:
  - tab on line 28 of src/test/java/org/devmaster/elasticsearch/plugin/RecurringSearchScriptTests.java

```

when executing

```auto
./gradlew clean build

```

Or

```auto
gradle clean build

```

Have a clue why that error?

---

<div class="post-metadata">

**Author:** ![dadoonet](https://sea2.discourse-cdn.com/elastic/user_avatar/discuss.elastic.co/dadoonet/32/137187_2.png) [@dadoonet](https://discuss.elastic.co/u/dadoonet)\
**Post date:** [April 1, 2019, 9:04pm UTC](https://discuss.elastic.co/t/how-to-use-esintegtestcase-in-elasticsearch-6-6-1/174646/6 "2019-04-01T21:04:24Z")

</div>

Most likely a tab instead of spaces.

---

<div class="post-metadata">

**Author:** ![EliuFlorez](https://sea2.discourse-cdn.com/elastic/user_avatar/discuss.elastic.co/eliuflorez/32/40884_2.png) [@EliuFlorez](https://discuss.elastic.co/u/EliuFlorez)\
**Post date:** [April 1, 2019, 9:18pm UTC](https://discuss.elastic.co/t/how-to-use-esintegtestcase-in-elasticsearch-6-6-1/174646/7 "2019-04-01T21:18:51Z")

</div>

wow eliminate all the tabs, that is to say without space enters does not have good style the code but good.

Now I have this error. Can you help me know what it is? por favor. 😃

```auto
$ ./gradlew clean build

> Configure project :
=======================================
Elasticsearch Build Hamster says Hello!
  Gradle Version : 5.2.1
  OS Info : Windows 7 6.1 (amd64)
  JDK Version : 11 (Oracle Corporation 11.0.2 [Java HotSpot(TM) 64-Bit Server VM 11.0.2+9-LTS])
  JAVA_HOME : C:\Program Files\Java\jdk-11.0.2
  Random Testing Seed : B59907BAF0CE17D1
=======================================

> Task :jar
Building without git revision id.

> Task :javadocJar
Building without git revision id.

> Task :sourcesJar
Building without git revision id.

> Task :namingConventions FAILED
Standard output:

Standard error:
Not all subclasses of LuceneTestCase match the naming convention. Concrete classes must end with [Tests]:
 * org.devmaster.elasticsearch.index.RecurringTest

FAILURE: Build failed with an exception.

* What went wrong:
Execution failed for task ':namingConventions'.
> Process 'command 'C:\Program Files\Java\jdk-11.0.2/bin/java'' finished with non-zero exit value 1

* Try:
Run with --stacktrace option to get the stack trace. Run with --info or --debug option to get more log output. Run with --scan to get full insights.

* Get more help at https://help.gradle.org

BUILD FAILED in 24s
31 actionable tasks: 28 executed, 3 up-to-date

```

---

<div class="post-metadata">

**Author:** ![jasontedor](https://sea2.discourse-cdn.com/elastic/user_avatar/discuss.elastic.co/jasontedor/32/66992_2.png) [@jasontedor](https://discuss.elastic.co/u/jasontedor)\
**Post date:** [April 1, 2019, 9:47pm UTC](https://discuss.elastic.co/t/how-to-use-esintegtestcase-in-elasticsearch-6-6-1/174646/8 "2019-04-01T21:47:42Z")

</div>

Are you reading these error messages? This one says the problem too:

```auto
Not all subclasses of LuceneTestCase match the naming convention. Concrete classes must end with [Tests]:
 * org.devmaster.elasticsearch.index.RecurringTest

```

---

<div class="post-metadata">

**Author:** ![EliuFlorez](https://sea2.discourse-cdn.com/elastic/user_avatar/discuss.elastic.co/eliuflorez/32/40884_2.png) [@EliuFlorez](https://discuss.elastic.co/u/EliuFlorez)\
**Post date:** [April 3, 2019, 12:27am UTC](https://discuss.elastic.co/t/how-to-use-esintegtestcase-in-elasticsearch-6-6-1/174646/9 "2019-04-03T00:27:52Z")

</div>

Thanks, the installer is compiled. now in junit tests. : D  
If I have an error here I will be. : D

---

<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:** [May 1, 2019, 12:28am UTC](https://discuss.elastic.co/t/how-to-use-esintegtestcase-in-elasticsearch-6-6-1/174646/10 "2019-05-01T00:28:01Z")

</div>

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