Draft Complete

This commit is contained in:
JohnHake 2020-02-12 12:24:49 -08:00
parent c83e24d8bd
commit b6a9cff1ba
12 changed files with 140 additions and 194 deletions

View File

@ -40,7 +40,7 @@ public class SimpleCodeInsightTest extends LightJavaCodeInsightFixtureTestCase {
} }
public void testFormatter() { public void testFormatter() {
myFixture.configureByFiles("FormatterTestData.simple"); myFixture.configureByFile("FormatterTestData.simple");
CodeStyle.getLanguageSettings(myFixture.getFile()).SPACE_AROUND_ASSIGNMENT_OPERATORS = true; CodeStyle.getLanguageSettings(myFixture.getFile()).SPACE_AROUND_ASSIGNMENT_OPERATORS = true;
CodeStyle.getLanguageSettings(myFixture.getFile()).KEEP_BLANK_LINES_IN_CODE = 2; CodeStyle.getLanguageSettings(myFixture.getFile()).KEEP_BLANK_LINES_IN_CODE = 2;
WriteCommandAction.writeCommandAction(getProject()).run(() -> { WriteCommandAction.writeCommandAction(getProject()).run(() -> {
@ -57,7 +57,7 @@ public class SimpleCodeInsightTest extends LightJavaCodeInsightFixtureTestCase {
} }
public void testFolding() { public void testFolding() {
myFixture.configureByFiles("DefaultTestData.simple"); myFixture.configureByFile("DefaultTestData.simple");
myFixture.testFolding(getTestDataPath() + "/FoldingTestData.java"); myFixture.testFolding(getTestDataPath() + "/FoldingTestData.java");
} }

View File

@ -13,8 +13,9 @@ Rather than the usual practice of using a folding builder to collapse a class, m
The `SimpleFoldingBuilder` replaces usages of properties with their values by default. The `SimpleFoldingBuilder` replaces usages of properties with their values by default.
Start by subclassing [`FoldingBuilderEx`](upsource:///community/platform/core-api/src/com/intellij/lang/folding/FoldingBuilderEx.java) Start by subclassing [`FoldingBuilderEx`](upsource:///community/platform/core-api/src/com/intellij/lang/folding/FoldingBuilderEx.java)
Note that `SimpleFoldingBuilder` also implements `DumbAware`, which means the class is allowed to run in dumb mode, when indices are in background update. Note that `SimpleFoldingBuilder` also implements [`DumbAware`](upsource:///platform/core-api/src/com/intellij/openapi/project/DumbAware.java), which means the class is allowed to run in dumb mode, when indices are in background update.
Implementing `DumbAware` is required for successful operation and testing.
> **NOTE** A folding builder must implement [`DumbAware`](upsource:///platform/core-api/src/com/intellij/openapi/project/DumbAware.java) to function in this tutorial and pass tests.
The `buildFoldRegions()` method searches down a PSI tree from `root` to find all literal expressions containing the [simple prefix](/tutorials/custom_language_support/annotator.md#define-an-annotator) `simple:`. The `buildFoldRegions()` method searches down a PSI tree from `root` to find all literal expressions containing the [simple prefix](/tutorials/custom_language_support/annotator.md#define-an-annotator) `simple:`.
The remainder of such a string is expected to contain a Simple language key, and so the text range is stored as a [`FoldingDescriptor`](upsource:///platform/core-api/src/com/intellij/lang/folding/FoldingDescriptor.java). The remainder of such a string is expected to contain a Simple language key, and so the text range is stored as a [`FoldingDescriptor`](upsource:///platform/core-api/src/com/intellij/lang/folding/FoldingDescriptor.java).

View File

@ -2,16 +2,15 @@
title: 4. Annotator Test title: 4. Annotator Test
--- ---
In this test we will check if the annotator, implemented in the This test checks if the Simple language annotator functionality, implemented in the [Annotator](/tutorials/custom_language_support/annotator.md) section of the Custom Language Support Tutorial, works as expected.
[Annotator](/tutorials/custom_language_support/annotator.md) section
of the
[Custom Language Support Tutorial](/tutorials/custom_language_support_tutorial.md)
works as expected.
### 4.1. Define test data ## 4.1. Define Input Test Data
The `DefaultTestData.simple` properties file is reused for this test.
Create a file *AnnotatorTestData.java*.
Create an input test file `AnnotatorTestData.java` in the `testData` directory.
This file contains two instances of Simple language embedded in the Java code.
The first instance is a valid use of the `simple:` prefix followed by the Simple language key `website`.
The second is a valid prefix but an invalid key, as noted by the test `<error>` [highlighting](/basics/testing_plugins/testing_highlighting.md).
```java ```java
public class Test { public class Test {
public static void main(String[] args) { public static void main(String[] args) {
@ -21,8 +20,10 @@ public class Test {
} }
``` ```
### 4.2. Define a test method ## 4.2. Define a Test Method
Add the `testAnnotator()` method to the `SimpleCodeInsightTest` class [previously defined](completion_test.md#define-a-test).
Again, this method configures the test fixture by using the test files.
It then calls the `checkHighlighting()` method to verify weak warnings.
```java ```java
public void testAnnotator() { public void testAnnotator() {
myFixture.configureByFiles("AnnotatorTestData.java", "DefaultTestData.simple"); myFixture.configureByFiles("AnnotatorTestData.java", "DefaultTestData.simple");
@ -30,6 +31,5 @@ public void testAnnotator() {
} }
``` ```
### 4.3. Run the test ## 4.3. Run the Test
[Run](completion_test.md#run-the-test) the test and make sure it's green.
Run the test and make sure it's green.

View File

@ -2,21 +2,24 @@
title: 9. Commenter Test title: 9. Commenter Test
--- ---
In this test we will check if the commenter, implemented in the [Commenter](/tutorials/custom_language_support/commenter.md) section of the [Custom Language Support Tutorial](/tutorials/custom_language_support_tutorial.md), works as we expect. This test will check if the commenter, implemented in the [Commenter](/tutorials/custom_language_support/commenter.md) section of the Custom Language Support Tutorial, works as expected.
### 9.1. Define a test method ### 9.1. Define a Test Method
Add the `testCommenter()` method to the `SimpleCodeInsightTest` class [previously defined](completion_test.md#define-a-test).
This test constructs a Simple language properties file containing one line, with the virtual caret positioned at the beginning of the line.
The test calls the commenter to insert a comment character at the caret, then verifies the results.
It again calls the line comment action to remove the comment character and verifies the results.
```java ```java
public void testCommenter() { public void testCommenter() {
myFixture.configureByText(SimpleFileType.INSTANCE, "<caret>website = http://en.wikipedia.org/"); myFixture.configureByText(SimpleFileType.INSTANCE, "<caret>website = http://en.wikipedia.org/");
CommentByLineCommentAction commentAction = new CommentByLineCommentAction(); CommentByLineCommentAction commentAction = new CommentByLineCommentAction();
commentAction.actionPerformedImpl(getProject(), myFixture.getEditor()); commentAction.actionPerformedImpl(getProject(), myFixture.getEditor());
myFixture.checkResult("#website = http://en.wikipedia.org/"); myFixture.checkResult("#website = http://en.wikipedia.org/");
commentAction.actionPerformedImpl(getProject(), myFixture.getEditor()); commentAction.actionPerformedImpl(getProject(), myFixture.getEditor());
myFixture.checkResult("website = http://en.wikipedia.org/"); myFixture.checkResult("website = http://en.wikipedia.org/");
} }
``` ```
### 9.2. Run the test ### 9.2. Run the Test
[Run](completion_test.md#run-the-test) the test and make sure it's green.
Run the test and make sure it's green.

View File

@ -2,15 +2,17 @@
title: 3. Completion Test title: 3. Completion Test
--- ---
This test checks if code completion, implemented in the [Reference Contributor](/tutorials/custom_language_support/reference_contributor.md) section of the Custom Language Support Tutorial, works as expected. This test checks if the Simple language code completion functionality, implemented in the [Reference Contributor](/tutorials/custom_language_support/reference_contributor.md) section of the Custom Language Support Tutorial, works as expected.
## 3.1. Define Test Data ## 3.1. Define Test Data
Create an input Simple file `DefaultTestData.simple` for the test. Create the `DefaultTestData.simple` properties file in the `testData` directory.
```bash ```bash
{% include /code_samples/simple_language_plugin/src/test/testData/DefaultTestData.simple %} {% include /code_samples/simple_language_plugin/src/test/testData/DefaultTestData.simple %}
``` ```
Create an input java file `CompleteTestData.java` for the test. Create a test input Java file `CompleteTestData.java` in the `testData` directory.
This file contains a Simple language snippet within the Java.
```java ```java
{% include /code_samples/simple_language_plugin/src/test/testData/CompleteTestData.java %} {% include /code_samples/simple_language_plugin/src/test/testData/CompleteTestData.java %}
``` ```
@ -18,7 +20,14 @@ Create an input java file `CompleteTestData.java` for the test.
## 3.2. Define a Test ## 3.2. Define a Test
Subclass `LightJavaCodeInsightFixtureTestCase` to create `SimpleCodeInsightTest`. Subclass `LightJavaCodeInsightFixtureTestCase` to create `SimpleCodeInsightTest`.
Override `getTestDataPath()`, and return the path from the root of this plugin module to the `testData` directory. 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()`.
At this point only one test is defined in `SimpleCodeInsightTest`: `testCompletion()`.
This method:
* Configures the test using the two input files.
* Calls the basic completion functionality.
Behind the scenes, this method call creates a list of possible elements to complete the embedded Simple language reference.
* Checks the list of possible element names to ensure it contains all Simple language completion possibilities.
```java ```java
public class SimpleCodeInsightTest extends LightJavaCodeInsightFixtureTestCase { public class SimpleCodeInsightTest extends LightJavaCodeInsightFixtureTestCase {
@Override @Override
@ -36,5 +45,10 @@ public class SimpleCodeInsightTest extends LightJavaCodeInsightFixtureTestCase {
} }
``` ```
## 3.3. Run the test ## 3.3. Run the Test
As [before](parsing_test.md#run-the-test), run the test and make sure it's green. Run the test by:
* Opening the Gradle Tool Window.
* Drill down to the `simple_language_plugin`.
You may need to reimport it as a Gradle project.
* Drill down under `simple_language_plugin` to the *test* task under *verification*.
* Run the *test* task.

View File

@ -2,51 +2,31 @@
title: 8. Find Usages Test title: 8. Find Usages Test
--- ---
In this test we will check if the find usages provider, implemented in the This test ensures the find usages provider, implemented in the [Find Usages Provider](/tutorials/custom_language_support/find_usages_provider.md) section of the Custom Language Support Tutorial, works correctly.
[Find Usages Provider](/tutorials/custom_language_support/find_usages_provider.md)
section of the
[Custom Language Support Tutorial](/tutorials/custom_language_support_tutorial.md),
works correctly.
### 8.1. Define test data ## 8.1. Define test data
Create the `FindUsagesTestData.simple` properties file in the `testData` directory.
Create a file *FindUsagesTestData.simple*.
```bash ```bash
# You are reading the ".properties" entry. {% include /code_samples/simple_language_plugin/src/test/testData/FindUsagesTestData.simple %}
! The exclamation mark can also mark text as comments.
<caret>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 a file *FindUsagesTestData.java*. Create the test file `FindUsagesTestData.java`, which contains one embedded Simple language prefix and key.
```java ```java
public class Test { {% include /code_samples/simple_language_plugin/src/test/testData/FindUsagesTestData.java %}
public static void main(String[] args) {
System.out.println("simple:website");
}
}
``` ```
### 8.2. Define a test method ## 8.2. Define a Test Method
Add the `testFindUsages()` method to the `SimpleCodeInsightTest` class [previously defined](completion_test.md#define-a-test).
This test verifies the find usage functionality will identify the "key with spaces".
```java ```java
public void testFindUsages() { public void testFindUsages() {
Collection<UsageInfo> usageInfos = myFixture.testFindUsages("FindUsagesTestData.simple", "FindUsagesTestData.java"); Collection<UsageInfo> usageInfos = myFixture.testFindUsages("FindUsagesTestData.simple", "FindUsagesTestData.java");
assertEquals(1, usageInfos.size()); assertEquals(1, usageInfos.size());
} }
``` ```
### 8.3. Run the test ## 8.3. Run the Test
[Run](completion_test.md#run-the-test) the test and make sure it's green.
Run the test and make sure it's green.

View File

@ -2,33 +2,26 @@
title: 7. Folding Test title: 7. Folding Test
--- ---
In this test we will check if the folding builder, implemented in the This test verifies the Simple language folding builder, implemented in the [Folding Builder](/tutorials/custom_language_support/folding_builder.md) section of the Custom Language Support Tutorial, works as expected.
[Folding Builder](/tutorials/custom_language_support/folding_builder.md)
section of the
[Custom Language Support Tutorial](/tutorials/custom_language_support_tutorial.md),
works as we expect.
### 7.1. Define test data > **NOTE** A folding builder must implement [`DumbAware`](upsource:///platform/core-api/src/com/intellij/openapi/project/DumbAware.java) to pass tests. See [Define a Folding Builder](/tutorials/custom_language_support/folding_builder.md#define-a-folding-builder) for more information.
Create a file *FoldingTestData.java*.
## 7.1. Define Test Data
Create a file `FoldingTestData.java` in the `testData` directory.
This java file contains markup instructions for three different cases of code folding.
```java ```java
public class Test { {% include /code_samples/simple_language_plugin/src/test/testData/FoldingTestData.java %}
public static void main(String[] args)<fold text=' { '> {
</fold>System.out.println("<fold text='http://en.wikipedia.org/'>simple:website</fold>");<fold text=' }'>
}</fold>
}
``` ```
### 7.2. Define a test ## 7.2. Define a Test
Add the `testFolding()` method to the `SimpleCodeInsightTest` class [previously defined](completion_test.md#define-a-test).
This test method reuses the `DefaultTestData.simple` properties file.
```java ```java
public void testFolding() { public void testFolding() {
myFixture.configureByFiles("DefaultTestData.simple"); myFixture.configureByFile("DefaultTestData.simple");
myFixture.testFolding(getTestDataPath() + "/FoldingTestData.java"); myFixture.testFolding(getTestDataPath() + "/FoldingTestData.java");
} }
``` ```
### 7.3. Run the test ## 7.3. Run the Test
[Run](completion_test.md#run-the-test) the test and make sure it's green.
Run the test and make sure it's green.

View File

@ -2,51 +2,36 @@
title: 5. Formatter Test title: 5. Formatter Test
--- ---
In this test we will check if the formatter, implemented in the This test checks if the Simple language formatter, implemented in the [Formatter](/tutorials/custom_language_support/formatter.md) section of the Custom Language Support Tutorial, works as expected.
[Formatter](/tutorials/custom_language_support/formatter.md)
section of the
[Custom Language Support Tutorial](/tutorials/custom_language_support_tutorial.md)
works as we expect.
### 5.1. Define test data ## 5.1. Define Test Data
Create the `FormatterTestData.simple` properties file in the `testData` directory.
Create a file *FormatterTestData.simple*.
```bash ```bash
# You are reading the ".properties" entry. {% include /code_samples/simple_language_plugin/src/test/testData/FormatterTestData.simple %}
! 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
``` ```
### 5.2. Define a test method ## 5.2. Define a Test Method
Add the `testFormatter()` method to the `SimpleCodeInsightTest` class [previously defined](completion_test.md#define-a-test).
* Again, this method configures the test fixture by using the test file.
* The code style Simple language settings for spaces and blank lines are set.
* The file is then formatted according to the settings.
* The formatted file is compared to the expected results in the benchmark file `DefaultTestData.simple`.
```java ```java
public void testFormatter() { public void testFormatter() {
myFixture.configureByFiles("FormatterTestData.simple"); myFixture.configureByFile("FormatterTestData.simple");
CodeStyleSettingsManager.getSettings(getProject()).SPACE_AROUND_ASSIGNMENT_OPERATORS = true; CodeStyle.getLanguageSettings(myFixture.getFile()).SPACE_AROUND_ASSIGNMENT_OPERATORS = true;
new WriteCommandAction.Simple(getProject()) { CodeStyle.getLanguageSettings(myFixture.getFile()).KEEP_BLANK_LINES_IN_CODE = 2;
@Override WriteCommandAction.writeCommandAction(getProject()).run(() -> {
protected void run() throws Throwable { CodeStyleManager.getInstance(getProject()).reformatText(myFixture.getFile(),
CodeStyleManager.getInstance(getProject()).reformatText(myFixture.getFile(), ContainerUtil.newArrayList(myFixture.getFile().getTextRange()));
ContainerUtil.newArrayList(myFixture.getFile().getTextRange())); });
}
}.execute();
myFixture.checkResultByFile("DefaultTestData.simple"); myFixture.checkResultByFile("DefaultTestData.simple");
} }
``` ```
### 5.3. Run the test ## 5.3. Run the Test
[Run](completion_test.md#run-the-test) the test and make sure it's green.
Run the test and make sure it's green.
>> **TIP** See also [`FormatterTestCase`](upsource:///platform/testFramework/src/com/intellij/psi/formatter/FormatterTestCase.java) as convenient base class. >> **TIP** See also [`FormatterTestCase`](upsource:///platform/testFramework/src/com/intellij/psi/formatter/FormatterTestCase.java) as convenient base class.

View File

@ -2,14 +2,16 @@
title: 2. Parsing Test title: 2. Parsing Test
--- ---
The first test checks if the parser, implemented in the [Lexer and Parser Definition](/tutorials/custom_language_support/lexer_and_parser_definition.md) section of the Custom Language Support Tutorial, works as expected. The first test checks if the Simple language parser, implemented in the [Lexer and Parser Definition](/tutorials/custom_language_support/lexer_and_parser_definition.md) section of the Custom Language Support Tutorial, works as expected.
## 2.1. Update Grammar and Regenerate the Parser ## 2.1. Update Grammar and Regenerate the Parser
Before creating the parsing test, ensure the parser definition (`Simple.bnf`) includes the lines shown below. Before creating the parsing test, ensure the parser definition (`Simple.bnf`) includes the lines shown below.
These additional lines facilitate testing mangled keys. These additional lines facilitate testing incorrect keys.
If the lines below are not present in `Simple.bnf`, replace the existing `property` definition with the lines below. If the lines below are not present in `Simple.bnf`, replace the existing `property` definition with the lines below.
Don't forget to regenerate the parser after updating the file! Don't forget to regenerate the parser after updating the file!
Right-click on the `Simple.bnf` file and select **Generate Parser Code**. Right-click on the `Simple.bnf` file and select **Generate Parser Code**.
```java ```java
property ::= (KEY? SEPARATOR VALUE?) | KEY { property ::= (KEY? SEPARATOR VALUE?) | KEY {
pin=3 pin=3
@ -22,7 +24,7 @@ private recover_property ::= !(KEY|SEPARATOR|COMMENT)
``` ```
## 2.2. Define Input Test Data ## 2.2. Define Input Test Data
Create a file *ParsingTestData.simple* in the *testData* folder. Create the *ParsingTestData.simple* properties file in the *testData* folder.
Note the last few lines define a purposely incorrect key. Note the last few lines define a purposely incorrect key.
```bash ```bash
{% include /code_samples/simple_language_plugin/src/test/testData/ParsingTestData.simple %} {% include /code_samples/simple_language_plugin/src/test/testData/ParsingTestData.simple %}

View File

@ -2,35 +2,30 @@
title: 10. Reference Test title: 10. Reference Test
--- ---
This test checks if references functionality, implemented in the [Reference Contributor](/tutorials/custom_language_support/reference_contributor.md) section of the Custom Language Support Tutorial, works as expected.
In this test we will check if references, implemented in the ## 10.1. Define Test Data
[Reference Contributor](/tutorials/custom_language_support/reference_contributor.md) This test reuses the Simple language properties file `DefaultTestData.simple`.
section of the
[Custom Language Support Tutorial](/tutorials/custom_language_support_tutorial.md),
works as we expect.
### 10.1. Define test data Create the test file `ReferenceTestData.java` in the `testData` directory.
This file has one Simple language prefix and key, with the caret placed after the key.
Create a file *ReferenceTestData.java*.
```java ```java
public class Test { {% include /code_samples/simple_language_plugin/src/test/testData/ReferenceTestData.java %}
public static void main(String[] args) {
System.out.println("simple:website<caret>");
}
}
``` ```
### 10.2. Define a test method ## 10.2. Define a Test Method
Add the `testReference()` method to the `SimpleCodeInsightTest` class [previously defined](completion_test.md#define-a-test).
This test is configured by the test files.
The fixture gets the `PsiElement` at the caret, then compares its value with the known value of that key.
```java ```java
public void testReference() { public void testReference() {
myFixture.configureByFiles("ReferenceTestData.java", "DefaultTestData.simple"); myFixture.configureByFiles("ReferenceTestData.java", "DefaultTestData.simple");
PsiElement element = myFixture.getFile().findElementAt(myFixture.getCaretOffset()).getParent(); PsiElement element = myFixture.getFile().findElementAt(myFixture.getCaretOffset()).getParent();
assertEquals("http://en.wikipedia.org/", ((SimpleProperty) element.getReferences()[0].resolve()).getValue()); assertEquals("http://en.wikipedia.org/", ((SimpleProperty) element.getReferences()[0].resolve()).getValue());
} }
``` ```
### 10.3. Run the test ## 10.3. Run the Test
[Run](completion_test.md#run-the-test) the test and make sure it's green.
Run the test and make sure it's green.

View File

@ -2,72 +2,44 @@
title: 6. Rename Test title: 6. Rename Test
--- ---
This test verifies the Simple language in-place rename functionality, implemented in the [Reference Contributor](/tutorials/custom_language_support/reference_contributor.md) section of the Custom Language Support Tutorial, works as expected.
In this test we will check if in-place rename, implemented in the ## 6.1. Define Input Test Data
[Reference Contributor](/tutorials/custom_language_support/reference_contributor.md) Create the `RenameTestData.simple` properties file in the `testData` directory.
section of the
[Custom Language Support Tutorial](/tutorials/custom_language_support_tutorial.md), works as we expect.
### 6.1. Define input test data
Create a file *RenameTestData.simple*.
```bash ```bash
# You are reading the ".properties" entry. {% include /code_samples/simple_language_plugin/src/test/testData/RenameTestData.simple %}
! 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 a file *RenameTestData.java*. Create the file `RenameTestData.java` in the `testData` directory.
This file contains one Simple language reference embedded in Java, with the [caret position](/basics/testing_plugins/test_project_and_testdata_directories.md#special-markup) placed just after a Simple language key.
```java ```java
public class Test { {% include /code_samples/simple_language_plugin/src/test/testData/RenameTestData.java %}
public static void main(String[] args) {
System.out.println("simple:website<caret>");
}
}
``` ```
### 6.2. Create output test data ## 6.2. Create Output Test Data
Create the `RenameTestDataAfter.simple` properties file in the `testData` directory.
Create a file *RenameTestDataAfter.simple*. This file contains the expected outcome of the test.
Note the `website =` in `RenameTestData.simple` should be renamed to `websiteUrl =` by the test.
```bash ```bash
# You are reading the ".properties" entry. {% include /code_samples/simple_language_plugin/src/test/testData/RenameTestDataAfter.simple %}
! The exclamation mark can also mark text as comments.
websiteUrl = 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
``` ```
### 6.3. Define a test method ## 6.3. Define a Test Method
Add the `testRename()` method to the `SimpleCodeInsightTest` class [previously defined](completion_test.md#define-a-test).
* Again, this method configures the test fixture by using the test files.
* The fixture then renames the Simple language element at the caret in `RenameTestData.java`.
* It then compares the input and output property files, ignoring whitespace.
```java ```java
public void testRename() { public void testRename() {
myFixture.configureByFiles("RenameTestData.java", "RenameTestData.simple"); myFixture.configureByFiles("RenameTestData.java", "RenameTestData.simple");
myFixture.renameElementAtCaret("websiteUrl"); myFixture.renameElementAtCaret("websiteUrl");
myFixture.checkResultByFile("RenameTestData.simple", "RenameTestDataAfter.simple", false); myFixture.checkResultByFile("RenameTestData.simple", "RenameTestDataAfter.simple", false);
} }
``` ```
### 6.4. Run the test ## 6.4. Run the Test
[Run](completion_test.md#run-the-test) the test and make sure it's green.
Run the test and make sure it's green.

View File

@ -20,11 +20,12 @@ Mark the `java` folder as a test source root via the context menu `Mark Director
Similarly, mark the `testData` folder as a test resource root via the context menu `Mark Directory As` &rarr; `Test Resources Root`. Similarly, mark the `testData` folder as a test resource root via the context menu `Mark Directory As` &rarr; `Test Resources Root`.
## 1.2. Set the Run Configuration Parameters ## 1.2. Set the Run Configuration Parameters
Since some of the tests use Java files as test data, the tests need to mock up the project SDK. Because some of the tests use Java files as test data, the tests need to mock up the project SDK.
IntelliJ IDEA does everything automatically when we use the utility class [`LightJavaCodeInsightFixtureTestCase`](upsource:///java/testFramework/src/com/intellij/testFramework/fixtures/LightJavaCodeInsightFixtureTestCase.java) as the basis for our tests. IntelliJ IDEA does everything automatically when the utility class [`LightJavaCodeInsightFixtureTestCase`](upsource:///java/testFramework/src/com/intellij/testFramework/fixtures/LightJavaCodeInsightFixtureTestCase.java) is used as the basis for the tests.
The system properties are defined in the `build.gradle` file using the snippet shown below. The system properties are defined in the `build.gradle` file using the snippet shown below.
The "/path/to/community/" is set to the absolute path to the root directory of the local intellij-community source on the machine running the tests. The "/path/to/community/" is set to the absolute path to the root directory of the local intellij-community source on the machine running the tests.
For example, on macOS the "path/to/community/" might be `/Users/<user name>/Documents/<community source root>/`
```groovy ```groovy
test { test {
systemProperty "idea.home.path", "/path/to/community/" systemProperty "idea.home.path", "/path/to/community/"