2

Can we use soft assert in Junit as like TestNG:

I dont want to fail my Test Case if Assert Condition fail

Any way to solve this use case

Kiran Yadav
  • 46
  • 1
  • 5

2 Answers2

3

You can use:

import org.assertj.core.api.SoftAssertions;

Code:

SoftAssertions softAssertions = new SoftAssertions();
softAssertions.assertThat(searchCriteriaPage.count()).isEqualTo(searchCriteria.getCount());
softAssertions.assertAll();

Maven Dependency:

<dependency>
    <groupId>org.assertj</groupId>
    <artifactId>assertj-core</artifactId>
    <version>3.18.1</version>
    <scope>test</scope>
</dependency>
double-beep
  • 5,031
  • 17
  • 33
  • 41
PDHide
  • 18,113
  • 2
  • 31
  • 46
-5

Yes we can do:

softAssertions = new SoftAssertions();
Kiran Yadav
  • 46
  • 1
  • 5