mirror of
https://github.com/JetBrains/intellij-sdk-code-samples.git
synced 2025-07-29 01:37:51 +08:00
2.0 KiB
2.0 KiB
title |
---|
3. Completion Test |
In this test we will check if code completion, implemented in the Reference Contributor section of the Custom Language Support Tutorial works as we expect.
3.1. Define test data
Create a file DefaultTestData.simple.
# You are reading the ".properties" entry.
! The exclamation mark can also mark text as comments.
website = http://en.wikipedia.org/
language = English
# The backslash below tells the application to continue reading
# the value onto the next line.
message = Welcome to \
Wikipedia!
# Add spaces to the key
key\ with\ spaces = This is the value that could be looked up with the key "key with spaces".
# Unicode
tab : \u0009
Create one more file CompleteTestData.java.
public class Test {
public static void main(String[] args) {
System.out.println("simple:<caret>");
}
}
3.2. Define a test
package com.simpleplugin;
import com.intellij.codeInsight.completion.CompletionType;
import com.intellij.testFramework.fixtures.LightCodeInsightFixtureTestCase;
import java.util.Arrays;
import java.util.List;
public class SimpleCodeInsightTest extends LightCodeInsightFixtureTestCase {
@Override
protected String getTestDataPath() {
return "../../SimplePlugin/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
Run the test and make sure it's green.