Recipe Name:
Use AssertJ's fail()
Description:
Use AssertJ's fail()
Level:
warning
Language:
  • java
Tags:
  • AssertJ
  • TestNG
Recipe
id: scw:assertj:testng-fail
version: 10
metadata:
  name: Use AssertJ's fail()
  shortDescription: Use AssertJ's fail()
  level: warning
  language: java
  enabled: true
  tags: AssertJ; TestNG
search:
  methodcall:
    with:
      anyOf:
      - argCount: 0
      - args:
          1:
            type: String
        argCount: 1
    argCount:
      lessThanOrEquals: 2
    name: fail
    type: org.testng.Assert
availableFixes:
- doStaticImports: true
  name: Use AssertJ's fail()
  availableIf:
    markedElement:
      is:
        methodcall:
          argCount: 0
  actions:
  - rewrite:
      to: org.assertj.core.api.Assertions.fail("")
      target: self
- doStaticImports: true
  name: Use AssertJ's fail(message)
  availableIf:
    markedElement:
      is:
        methodcall:
          argCount: 1
  actions:
  - rewrite:
      to: org.assertj.core.api.Assertions.fail({{{ arguments.0 }}})