This rule is an example of custom rules targeting only TEST code.It is not a common good practice, but a simple illustration of what can be achieved when writing rules.

In particular, this rule targets test methods (method annotated with JUnit4 @Test annotation) that contain an "if" statement, completely arbitrarily. A possible reasoning could be that some people might feel a test should not have any conditional path.

Noncompliant Code Example

@Test
public void my_test_method() {
  if (someCondition) {
    // verify something
  } else {
    // verify something else
  }
}

Compliant Solution

@Test
public void my_first_test_method() {
  // verify something
}

@Test
public void my_second_test_method() {
  // verify something else
}