Recipe Name:
JUnit 4: Incorrect method signature for annotation
Description:
The annotations on this method require it to have a void return type and not be private.
Level:
error
Language:
  • java
  • kotlin
Tags:
  • testing
  • framework specific
  • JUnit 4
  • quality
Recipe
id: scw:java:junit4:annotation-method-signature
version: 10
metadata:
  name: 'JUnit 4: Incorrect method signature for annotation'
  shortDescription: The annotations on this method require it to have a void return type and not be private.
  level: error
  language: java; kotlin
  enabled: true
  comment: http://junit.sourceforge.net/javadoc/org/junit/Before.html
  tags: testing;framework specific;JUnit 4;quality
search:
  method:
    annotation:
      label: beforeannotation
      type:
        reference:
          matches: org.junit.(Before|After)
        checkInheritance: true
    anyOf:
    - modifier:
        not: public
    - returnType:
        not: void
        checkInheritance: true
availableFixes:
- name: Remove annotation
  actions:
  - remove:
      target: label:beforeannotation
- name: Change method to public void
  actions:
  - changeModifiers:
      visibility: public
  - changeType:
      type: void