Recipe Name:
JUnit 4: @Ignored Description
Description:
Add a description to indicate why the test has been ignored.
Level:
warning
Language:
  • java
Tags:
  • testing
  • framework specific
  • JUnit 4
  • quality
Documentation

Whenever a test is ignored, e.g. using the @Ignore annotation, a reason for ignoring the test should be added. The @Ignore annotation supports this by providing an argument.

Before
@Ignore
void thisTestIsIgnored() {
  ...
}
After
@Ignore("TODO: Add a reason for ignoring the test")
void thisTestIsIgnored() {
  ...
}
References
Recipe
id: scw:java:junit4:ignored-description
version: 10
metadata:
  name: 'JUnit 4: @Ignored Description'
  shortDescription: Add a description to indicate why the test has been ignored.
  level: warning
  language: java
  enabled: true
  descriptionFile: descriptions/JUnit_Ignored_Description.html
  tags: testing;framework specific;JUnit 4;quality
search:
  annotation:
    type: org.junit.Ignore
    without:
      parameters:
      - {}
availableFixes:
- name: Add a todo comment parameter
  actions:
  - rewrite:
      to: '{{{ . }}}("TODO: Add a reason for ignoring the test")'
      target: self