diff --git a/_SUMMARY.md b/_SUMMARY.md index 7020b15d2..d16e0f209 100644 --- a/_SUMMARY.md +++ b/_SUMMARY.md @@ -68,7 +68,7 @@ * [Parsing Test](parsing_test.html) * [Completion Test](completion_test.html) * [Annotator Test](annotator_test.html) - * [Formatter Test](TODO) + * [Formatter Test](formatter_test.html) * [Rename Test](TODO) * [Folding Test](TODO) * [Find Usages Test](TODO) diff --git a/formatter_test.md b/formatter_test.md new file mode 100644 index 000000000..0078bea80 --- /dev/null +++ b/formatter_test.md @@ -0,0 +1,57 @@ +--- +title: Formatter Test +--- + + + +# {{ page.title }} + +In this test we will check if the formatter, implemented in the +[Formatter](formatter.html) +section of the +[Custom Language Support Tutorial](cls_tutorial.html) +works as we expect. + +### 1. Define test data + +Create a file *FormatterTestData.simple*. + +```bash +# 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 +``` + +### 2. Define a test method + +```java +public void testFormatter() { + myFixture.configureByFiles("FormatterTestData.simple"); + CodeStyleSettingsManager.getSettings(getProject()).SPACE_AROUND_ASSIGNMENT_OPERATORS = true; + ApplicationManager.getApplication().runWriteAction(new Runnable() { + @Override + public void run() { + CodeStyleManager.getInstance(getProject()).reformat(myFixture.getFile()); + } + }); + myFixture.checkResultByFile("DefaultTestData.simple"); +} +``` + +### 3. Run the test + +Run the test and make sure it's green. + +[Previous](annotator_test.html) [Top](writing_tests_for_plugins.html) [Next](rename_test.html) \ No newline at end of file diff --git a/writing_tests_for_plugins.md b/writing_tests_for_plugins.md index 21c47880e..05198371e 100644 --- a/writing_tests_for_plugins.md +++ b/writing_tests_for_plugins.md @@ -18,7 +18,7 @@ and cover its code with functional tests. * [Parsing Test](parsing_test.html)) * [Completion Test](completion_test.html) * [Annotator Test](annotator_test.html) -* [Formatter Test](TODO) +* [Formatter Test](formatter_test.html) * [Rename Test](TODO) * [Folding Test](TODO) * [Find Usages Test](TODO)