ChangeAnnotation

Changing the annotation parameters.

Description

The changeAnnotation action allows for the modification of annotation parameters

Configuration options

addParameter

Add a parameter to the annotation. Two properties can be set: name (optional) and value.

changeAnnotation:
  addParameter:
    value: "\"Reason to disable\""
- @Disabled
+ @Disabled("Reason to disable")
  void thisTestMethodHasNoDisabledReason(){
      Assertions.fail("This test is disabled and should not run");
  }
changeAnnotation:
  addParameter:
    name: "value"
    value: "\"my-value\""
- @MyAnnotation(param1 = "")
+ @MyAnnotation(param1 = "", value = "my-value")
  private String s;

- @MyAnnotation
+ @MyAnnotation("my-value")
  private int i;
changeAnnotation:
  addParameter:
  - name: "param3"
    value: 5
  - name: "param2"
    value: "\"\""
- @MyAnnotation(param1 = "")
+ @MyAnnotaion(param1 = "", param2 = "", param3 = 5)
  void myMethod() {
      // ...
  }

Note

The parameters will be added in alphabetical order

changeParameter

Change an existing parameter's name or value, depending on the options given.

name

This options will change the name of the parameter that matches the given name in the from property.

changeAnnotation:
  changeParameter:
  - name:
      from: "name"
      to: "myName"
- @MyAnnotation(name = "")
+ @MyAnnotation(myName = "")
  private String s;

value

This options will change the value of the parameter that matches the given name in the withName property.

changeAnnotation:
  changeParameter:
  - value:
      withName: "name"
      to: "\"s\""
- @MyAnnotation(name = "")
+ @MyAnnotation(name = "s")
  private String s;

removeParameter

Removes the parameter from the annotation that matches the given name in the withName property.

changeAnnotation:
  removeParameter:
  - withName: "name"
- @MyAnnotation(name = "")
+ @MyAnnotation()
  private String s;

type

Changes the type of the annotation.

changeAnnotation:
  changeParameter:
  - type: "com.example.MyNewAnnotation"
- @MyOldAnnotation(name = "s")
+ @MyNewAnnotation(name = "s")
  private String s;