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|Formatter Test] {span:class=sep}\|{span} {span:class=text}Formatter 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|Folding Test] {span:class=sep}\|{span} {span:class=text}Folding Test{span}{align} {td}
 {tr}
{table}
{div}

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

1. Define input test data

Create a file "RenameTestData.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

Create a file "RenameTestData.java".

Code Block

public class Test {
    public static void main(String[] args) {
        System.out.println("simple:website<caret>");
    }
}

2. Create output test data

Create a file "RenameTestDataAfter.simple".

Code Block

# You are reading the ".properties" entry.
! 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

3. Define a test method

Code Block

public void testRename() {
    myFixture.configureByFiles("RenameTestData.java", "RenameTestData.simple");
    myFixture.renameElementAtCaret("websiteUrl");
    myFixture.checkResultByFile("RenameTestData.simple", "RenameTestDataAfter.simple", false);
}

4. 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|Formatter Test] {span:class=sep}\|{span} {span:class=text}Formatter 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|Folding Test] {span:class=sep}\|{span} {span:class=text}Folding Test{span}{align} {td}
 {tr}
{table}
{div}

 

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