Versions Compared

Key

  • This line was added.
  • This line was removed.
  • Formatting was changed.
Wiki Markup
{div:class=navigation}
{table:width=100%}
 {tr}
  {td} {align:left}[Previous|Annotator Test] {span:class=sep}\|{span} {span:class=text}Annotator Test{span}{align} {td}
  {td} {align:center}[Top|Writing Tests for Plugins] {span:class=sep}\|{span} {span:class=text}Writing Tests for Plugins{span}{align} {td}
  {td} {align:right}[Next|Rename Test] {span:class=sep}\|{span} {span:class=text}Rename Test{span}{align} {td}
 {tr}
{table}
{div}

In this test we will check if the formatter, implemented in the previous tutorial, works as we expect.

1. Define test data

Create a file "FormatterTestData.simple".

Code Block

# 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

Code Block

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.

Wiki Markup
{div:class=navigation}
{table:width=100%}
 {tr}
  {td} {align:left}[Previous|Annotator Test] {span:class=sep}\|{span} {span:class=text}Annotator Test{span}{align} {td}
  {td} {align:center}[Top|Writing Tests for Plugins] {span:class=sep}\|{span} {span:class=text}Writing Tests for Plugins{span}{align} {td}
  {td} {align:right}[Next|Rename Test] {span:class=sep}\|{span} {span:class=text}Rename Test{span}{align} {td}
 {tr}
{table}
{div}

 

Redirect
locationhttp://www.jetbrains.org/intellij/sdk/docs/tutorials/writing_tests_for_plugins/formatter_test.html