mirror of
https://github.com/JetBrains/intellij-sdk-code-samples.git
synced 2025-07-27 16:57:49 +08:00
Extract running custom language tests into snippet
This commit is contained in:
parent
84ae397503
commit
db99d82b8c
27
topics/_shared/custom_language_testing_snippets.md
Normal file
27
topics/_shared/custom_language_testing_snippets.md
Normal file
@ -0,0 +1,27 @@
|
||||
# Snippets
|
||||
{is-library="true"}
|
||||
|
||||
<!-- Copyright 2000-2022 JetBrains s.r.o. and contributors. Use of this source code is governed by the Apache 2.0 license. -->
|
||||
|
||||
<snippet id="runTests">
|
||||
|
||||
Run the test and make sure it's successful.
|
||||
|
||||
<procedure title="Running tests" collapsible="true" default-state="collapsed">
|
||||
|
||||
1. Open the <control>Gradle</control> Tool Window.
|
||||
2. Select the <control>simple_language_plugin</control> node.
|
||||
You may need to reimport it as a Gradle project.
|
||||
3. Drill down under <control>simple_language_plugin</control> to <control>Tasks</control>, <control>verification</control>, <control>test</control> task.
|
||||
4. Run the <control>test</control> task.
|
||||
|
||||
The results are displayed in the <control>Run</control> Tool Window, and also written to the <path>simple_language_plugin/build/test-results/test</path> directory.
|
||||
|
||||
If the <control>Run</control> Tool Window displays the error *Test events were not received*, do the following:
|
||||
1. In the <control>Gradle</control> Tool Window, drill down under <control>simple_language_plugin</control> to <control>Tasks</control>, <control>build</control>, <control>clean</control> task.
|
||||
2. Run the <control>clean</control> task, which deletes the <path>simple_language_plugin/build</path> directory.
|
||||
3. Restart the test.
|
||||
|
||||
</procedure>
|
||||
|
||||
</snippet>
|
@ -1,6 +1,6 @@
|
||||
[//]: # (title: 4. Annotator Test)
|
||||
# 4. Annotator Test
|
||||
|
||||
<!-- Copyright 2000-2022 JetBrains s.r.o. and other contributors. Use of this source code is governed by the Apache 2.0 license that can be found in the LICENSE file. -->
|
||||
<!-- Copyright 2000-2022 JetBrains s.r.o. and contributors. Use of this source code is governed by the Apache 2.0 license. -->
|
||||
|
||||
<tldr>
|
||||
|
||||
@ -37,4 +37,5 @@ It then calls the `checkHighlighting()` method to verify weak warnings.
|
||||
{src="simple_language_plugin/src/test/java/org/intellij/sdk/language/SimpleCodeInsightTest.java" include-symbol="testAnnotator"}
|
||||
|
||||
## Run the Test
|
||||
[Run](parsing_test.md#run-the-test) the test and make sure it's green.
|
||||
|
||||
<include from="custom_language_testing_snippets.md" element-id="runTests"/>
|
||||
|
@ -1,6 +1,6 @@
|
||||
[//]: # (title: 9. Commenter Test)
|
||||
# 9. Commenter Test
|
||||
|
||||
<!-- Copyright 2000-2022 JetBrains s.r.o. and other contributors. Use of this source code is governed by the Apache 2.0 license that can be found in the LICENSE file. -->
|
||||
<!-- Copyright 2000-2022 JetBrains s.r.o. and contributors. Use of this source code is governed by the Apache 2.0 license. -->
|
||||
|
||||
<tldr>
|
||||
|
||||
@ -21,4 +21,5 @@ It again calls the line comment action to remove the comment character and verif
|
||||
{src="simple_language_plugin/src/test/java/org/intellij/sdk/language/SimpleCodeInsightTest.java" include-symbol="testCommenter"}
|
||||
|
||||
## Run the Test
|
||||
[Run](parsing_test.md#run-the-test) the test and make sure it's green.
|
||||
|
||||
<include from="custom_language_testing_snippets.md" element-id="runTests"/>
|
||||
|
@ -1,6 +1,6 @@
|
||||
[//]: # (title: 3. Completion Test)
|
||||
# 3. Completion Test
|
||||
|
||||
<!-- Copyright 2000-2022 JetBrains s.r.o. and other contributors. Use of this source code is governed by the Apache 2.0 license that can be found in the LICENSE file. -->
|
||||
<!-- Copyright 2000-2022 JetBrains s.r.o. and contributors. Use of this source code is governed by the Apache 2.0 license. -->
|
||||
|
||||
<tldr>
|
||||
|
||||
@ -48,4 +48,5 @@ This method:
|
||||
A number of related methods exist in [`CodeInsightTestFixture`](%gh-ic%/platform/testFramework/src/com/intellij/testFramework/fixtures/CodeInsightTestFixture.java) for testing completion and lookup elements, e.g., when testing completion variants and requiring only one testdata file `CodeInsightTestFixture.testCompletionVariants()`.
|
||||
|
||||
## Run the Test
|
||||
[Run](parsing_test.md#run-the-test) the test and make sure it's green.
|
||||
|
||||
<include from="custom_language_testing_snippets.md" element-id="runTests"/>
|
||||
|
@ -1,6 +1,6 @@
|
||||
[//]: # (title: 11. Documentation Test)
|
||||
# 11. Documentation Test
|
||||
|
||||
<!-- Copyright 2000-2022 JetBrains s.r.o. and other contributors. Use of this source code is governed by the Apache 2.0 license that can be found in the LICENSE file. -->
|
||||
<!-- Copyright 2000-2022 JetBrains s.r.o. and contributors. Use of this source code is governed by the Apache 2.0 license. -->
|
||||
|
||||
<tldr>
|
||||
|
||||
@ -24,4 +24,5 @@ Finally, the documentation string is verified against the expected output.
|
||||
{src="simple_language_plugin/src/test/java/org/intellij/sdk/language/SimpleCodeInsightTest.java" include-symbol="testDocumentation"}
|
||||
|
||||
## Run the Test
|
||||
[Run](parsing_test.md#run-the-test) the test and make sure it's green.
|
||||
|
||||
<include from="custom_language_testing_snippets.md" element-id="runTests"/>
|
||||
|
@ -1,6 +1,6 @@
|
||||
[//]: # (title: 8. Find Usages Test)
|
||||
# 8. Find Usages Test
|
||||
|
||||
<!-- Copyright 2000-2022 JetBrains s.r.o. and other contributors. Use of this source code is governed by the Apache 2.0 license that can be found in the LICENSE file. -->
|
||||
<!-- Copyright 2000-2022 JetBrains s.r.o. and contributors. Use of this source code is governed by the Apache 2.0 license. -->
|
||||
|
||||
<tldr>
|
||||
|
||||
@ -33,4 +33,5 @@ This test verifies the find usage functionality will identify the "key with spac
|
||||
|
||||
|
||||
## Run the Test
|
||||
[Run](parsing_test.md#run-the-test) the test and make sure it's green.
|
||||
|
||||
<include from="custom_language_testing_snippets.md" element-id="runTests"/>
|
||||
|
@ -1,6 +1,6 @@
|
||||
[//]: # (title: 7. Folding Test)
|
||||
# 7. Folding Test
|
||||
|
||||
<!-- Copyright 2000-2022 JetBrains s.r.o. and other contributors. Use of this source code is governed by the Apache 2.0 license that can be found in the LICENSE file. -->
|
||||
<!-- Copyright 2000-2022 JetBrains s.r.o. and contributors. Use of this source code is governed by the Apache 2.0 license. -->
|
||||
|
||||
<tldr>
|
||||
|
||||
@ -33,4 +33,5 @@ This test method reuses the <path>DefaultTestData.simple</path> Simple file.
|
||||
|
||||
|
||||
## Run the Test
|
||||
[Run](parsing_test.md#run-the-test) the test and make sure it's green.
|
||||
|
||||
<include from="custom_language_testing_snippets.md" element-id="runTests"/>
|
||||
|
@ -1,6 +1,6 @@
|
||||
[//]: # (title: 5. Formatter Test)
|
||||
# 5. Formatter Test
|
||||
|
||||
<!-- Copyright 2000-2022 JetBrains s.r.o. and other contributors. Use of this source code is governed by the Apache 2.0 license that can be found in the LICENSE file. -->
|
||||
<!-- Copyright 2000-2022 JetBrains s.r.o. and contributors. Use of this source code is governed by the Apache 2.0 license. -->
|
||||
|
||||
<tldr>
|
||||
|
||||
@ -31,4 +31,5 @@ Add the `testFormatter()` method to the `SimpleCodeInsightTest` class [previousl
|
||||
{src="simple_language_plugin/src/test/java/org/intellij/sdk/language/SimpleCodeInsightTest.java" include-symbol="testFormatter"}
|
||||
|
||||
## Run the Test
|
||||
[Run](parsing_test.md#run-the-test) the test and make sure it's green.
|
||||
|
||||
<include from="custom_language_testing_snippets.md" element-id="runTests"/>
|
||||
|
@ -1,6 +1,6 @@
|
||||
[//]: # (title: 2. Parsing Test)
|
||||
# 2. Parsing Test
|
||||
|
||||
<!-- Copyright 2000-2022 JetBrains s.r.o. and other contributors. Use of this source code is governed by the Apache 2.0 license that can be found in the LICENSE file. -->
|
||||
<!-- Copyright 2000-2022 JetBrains s.r.o. and contributors. Use of this source code is governed by the Apache 2.0 license. -->
|
||||
|
||||
<tldr>
|
||||
|
||||
@ -64,16 +64,4 @@ Override `getTestDataPath()`, and return the path from the root of this plugin m
|
||||
|
||||
## Run the Test
|
||||
|
||||
Run tests by:
|
||||
* Opening the <control>Gradle</control> Tool Window.
|
||||
* Select the <control>simple_language_plugin</control> node.
|
||||
You may need to reimport it as a Gradle project.
|
||||
* Drill down under <control>simple_language_plugin</control> to <control>Tasks</control>, <control>verification</control>, <control>test</control> task.
|
||||
* Run the <control>test</control> task.
|
||||
|
||||
The results are displayed in the <control>Run</control> Tool Window, and also written to the <path>simple_language_plugin/build/test-results/test</path> directory.
|
||||
|
||||
If the <control>Run</control> Tool Window displays the error *Test events were not received*, do the following:
|
||||
* In the <control>Gradle</control> Tool Window, drill down under <control>simple_language_plugin</control> to <control>Tasks</control>, <control>build</control>, <control>clean</control> task.
|
||||
* Run the <control>clean</control> task, which deletes the <path>simple_language_plugin/build</path> directory.
|
||||
* Restart the test.
|
||||
<include from="custom_language_testing_snippets.md" element-id="runTests"/>
|
||||
|
@ -1,6 +1,6 @@
|
||||
[//]: # (title: 10. Reference Test)
|
||||
# 10. Reference Test
|
||||
|
||||
<!-- Copyright 2000-2022 JetBrains s.r.o. and other contributors. Use of this source code is governed by the Apache 2.0 license that can be found in the LICENSE file. -->
|
||||
<!-- Copyright 2000-2022 JetBrains s.r.o. and contributors. Use of this source code is governed by the Apache 2.0 license. -->
|
||||
|
||||
<tldr>
|
||||
|
||||
@ -29,6 +29,6 @@ The fixture gets the `PsiReference` at the caret position, and then asserts the
|
||||
```
|
||||
{src="simple_language_plugin/src/test/java/org/intellij/sdk/language/SimpleCodeInsightTest.java" include-symbol="testReference"}
|
||||
|
||||
|
||||
## Run the Test
|
||||
[Run](parsing_test.md#run-the-test) the test and make sure it's green.
|
||||
|
||||
<include from="custom_language_testing_snippets.md" element-id="runTests"/>
|
||||
|
@ -1,6 +1,6 @@
|
||||
[//]: # (title: 6. Rename Test)
|
||||
# 6. Rename Test
|
||||
|
||||
<!-- Copyright 2000-2022 JetBrains s.r.o. and other contributors. Use of this source code is governed by the Apache 2.0 license that can be found in the LICENSE file. -->
|
||||
<!-- Copyright 2000-2022 JetBrains s.r.o. and contributors. Use of this source code is governed by the Apache 2.0 license. -->
|
||||
|
||||
<tldr>
|
||||
|
||||
@ -45,4 +45,5 @@ Add the `testRename()` method to the `SimpleCodeInsightTest` class [previously d
|
||||
|
||||
|
||||
## Run the Test
|
||||
[Run](parsing_test.md#run-the-test) the test and make sure it's green.
|
||||
|
||||
<include from="custom_language_testing_snippets.md" element-id="runTests"/>
|
||||
|
Loading…
x
Reference in New Issue
Block a user