Uploaded image for project: 'SonarJava'
  1. SonarJava
  2. SONARJAVA-3324

FP in S2970 when using JUnit 5 Soft assertions extension.

    XMLWordPrintable

    Details

    • Type: False-Positive
    • Status: Closed
    • Priority: Major
    • Resolution: Fixed
    • Affects Version/s: None
    • Fix Version/s: 6.4
    • Component/s: Rules
    • Labels:

      Description

      JUnit 5 Soft assertions extension will call assertAll() at the end of each test, we should not report any issue when the class extends SoftAssertionsExtension.class.
      See documentation.

      @ExtendWith(SoftAssertionsExtension.class)
      class JUnit5SoftAssertionsExample {
        @Test
        void junit5_soft_assertions_example(org.assertj.core.api.SoftAssertions softly) {
          softly.assertThat(5).isLessThan(3);
          // No need to call softly.assertAll(), this is automatically done by the SoftAssertionsExtension
        }
      }
      

        Attachments

          Issue Links

            Activity

              People

              Assignee:
              quentin.jaquier Quentin Jaquier
              Reporter:
              quentin.jaquier Quentin Jaquier
              Votes:
              0 Vote for this issue
              Watchers:
              2 Start watching this issue

                Dates

                Due:
                Created:
                Updated:
                Resolved: