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|IDEADEV:Commenter Test] {span:class=sep}\|{span} {span:class=text}Commenter Test{span}{align} {td}
  {td} {align:right}[Top|IDEADEV:Writing Tests for Plugins] {span:class=sep}\|{span} {span:class=text}Writing Tests for Plugins{span}{align} {td}
 {tr}
{table}
{div}

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

1. Define test data

Create a file "ReferenceTestData.java".

Code Block

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

2. Define a test method

Code Block

public void testReference() {
    myFixture.configureByFiles("ReferenceTestData.java", "DefaultTestData.simple");
    PsiElement element = myFixture.getFile().findElementAt(myFixture.getCaretOffset()).getParent();
    assertEquals("http://en.wikipedia.org/", ((SimpleProperty) element.getReferences()[0].resolve()).getValue());
}

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|IDEADEV:Commenter Test] {span:class=sep}\|{span} {span:class=text}Commenter Test{span}{align} {td}
  {td} {align:right}[Top|IDEADEV:Writing Tests for Plugins] {span:class=sep}\|{span} {span:class=text}Writing Tests for Plugins{span}{align} {td}
 {tr}
{table}
{div}

 

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