mirror of
https://github.com/JetBrains/intellij-sdk-code-samples.git
synced 2025-07-29 01:37:51 +08:00
1.5 KiB
1.5 KiB
title |
---|
3. Completion Test |
This test checks if code completion, implemented in the Reference Contributor section of the Custom Language Support Tutorial, works as expected.
3.1. Define Test Data
Create an input Simple file DefaultTestData.simple
for the test.
{% include /code_samples/simple_language_plugin/src/test/testData/DefaultTestData.simple %}
Create an input java file CompleteTestData.java
for the test.
{% include /code_samples/simple_language_plugin/src/test/testData/CompleteTestData.java %}
3.2. Define a Test
Subclass LightJavaCodeInsightFixtureTestCase
to create SimpleCodeInsightTest
.
Override getTestDataPath()
, and return the path from the root of this plugin module to the testData
directory.
At this point only one test is defined, testCompletion()
.
public class SimpleCodeInsightTest extends LightJavaCodeInsightFixtureTestCase {
@Override
protected String getTestDataPath() {
return "src/test/testData";
}
public void testCompletion() {
myFixture.configureByFiles("CompleteTestData.java", "DefaultTestData.simple");
myFixture.complete(CompletionType.BASIC, 1);
List<String> strings = myFixture.getLookupElementStrings();
assertTrue(strings.containsAll(Arrays.asList("key with spaces", "language", "message", "tab", "website")));
assertEquals(5, strings.size());
}
}
3.3. Run the test
As before, run the test and make sure it's green.