ChainedAssertionLosesContext
Inside a Subject, use check(...) instead of assert*() to preserve user-supplied messages and other settings.

Severity
WARNING
Has Fix?

The problem

Assertions made inside the implementation of another Truth assertion should use check, not assertThat.

Before:

class MyProtoSubject extends Subject {
  ...

  public void hasFoo(Foo expected) {
    assertThat(actual.foo()).isEqualTo(expected);
  }
}

After:

class MyProtoSubject extends Subject {
  ...

  public void hasFoo(Foo expected) {
    check("foo()").that(actual.foo()).isEqualTo(expected);
  }
}

Benefits of check include:

Suppression

Suppress false positives by adding the suppression annotation @SuppressWarnings("ChainedAssertionLosesContext") to the enclosing element.