Skip to content

Latest commit

 

History

History
26 lines (22 loc) · 1.46 KB

File metadata and controls

26 lines (22 loc) · 1.46 KB
title
9. Commenter Test

This test will check if the commenter, implemented in the Commenter section of the Custom Language Support Tutorial, works as expected.

9.1. Define a Test Method

Add the testCommenter() method to the SimpleCodeInsightTest class previously defined. This test constructs a Simple Language properties file containing one line, with the virtual caret positioned at the beginning of the line. The test calls the commenter to insert a comment character at the caret, then verifies the results. It again calls the line comment action to remove the comment character and verifies the results.

  public void testCommenter() {
    myFixture.configureByText(SimpleFileType.INSTANCE, "<caret>website = https://en.wikipedia.org/");
    CommentByLineCommentAction commentAction = new CommentByLineCommentAction();
    commentAction.actionPerformedImpl(getProject(), myFixture.getEditor());
    myFixture.checkResult("#website = https://en.wikipedia.org/");
    commentAction.actionPerformedImpl(getProject(), myFixture.getEditor());
    myFixture.checkResult("website = https://en.wikipedia.org/");
  }

9.2. Run the Test

Run the test and make sure it's green.