@org.junit.jupiter.api.extension.ExtendWith(org.assertj.core.api.junit.jupiter.SoftAssertionsExtension.class)
class JUnit5SoftAssertionsExample {
@org.assertj.core.api.junit.jupiter.InjectSoftAssertions
private org.assertj.core.api.SoftAssertions softly;
@org.junit.jupiter.api.Test
void junit5_soft_assertions_example() {
softly.assertThat(5).isLessThan(3);
// No need to call softly.assertAll(), this is automatically done by the SoftAssertionsExtension
}
}
@Colin Same here.
I’m using SonarLint 8.0.0.63273 in IntelliJ IDEA 2022.2.4 (Ultimate Edition).
Interestingly, If @ExtendWith(SoftAssertionsExtension.class) precedes any other @ExtendsWith statements, it correctly works (no false positives).
Thank you for reporting the issue.
I created the below example and I could not reproduce your issue.
I am on SonarLint-IntelliJ 8.1.0.63931.
package org.example;
import org.assertj.core.api.SoftAssertions;
import org.junit.jupiter.api.extension.ExtendWith;
import org.mockito.junit.jupiter.MockitoExtension;
@ExtendWith(MockitoExtension.class)
@ExtendWith(org.assertj.core.api.junit.jupiter.SoftAssertionsExtension.class)
class JUnit5SoftAssertionsExample {
SoftAssertions softly = new SoftAssertions();
@org.junit.jupiter.api.Test
void junit5_soft_assertions_example() {
softly.assertThat(5).isLessThan(3);
// No need to call softly.assertAll(), this is automatically done by the SoftAssertionsExtension
}
}
Hi @chrislain, How did you get the version of SonarLint plugin?
The latest version available is 8.0.0.63273 as shown here.
By the way, my usage of SoftAssertionExtension was slightly wrong. I’ve updated IntelliJ Ultimate to 2022.3.3 and then fixed the code, but the result was same.
@chrislainThe example you posted can reproduce the issue.
Is the version of the SonarLint plugin an internal release or something else? Could you downgrade the SonarLint plugin to 8.0.0.63273?
I’m jumping in just to highlight that a ticket was created to tackle the issue, since some time has passed and it could have been missed in the thread.