Skip to content

Commit d01ed5c

Browse files
AssertJ Demo SoftAssertion
1 parent 2fbcb9b commit d01ed5c

File tree

1 file changed

+9
-0
lines changed

1 file changed

+9
-0
lines changed

src/test/java/demo/assertJ/AssertJ.java

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,6 @@
11
package demo.assertJ;
22

3+
import org.assertj.core.api.SoftAssertions;
34
import org.assertj.core.data.Offset;
45
import org.assertj.core.data.Percentage;
56
import org.assertj.jodatime.api.Assertions;
@@ -139,6 +140,14 @@ public static void main(String[] args) throws IOException {
139140
assertThat(val.length()).isGreaterThan(4);
140141
});
141142

143+
//Soft Assertions
144+
SoftAssertions softAssertions=new SoftAssertions();
145+
softAssertions.assertThat(s1)
146+
.isInstanceOf(Student.class)
147+
.extracting(s -> s.getName())
148+
.isEqualTo("James");
149+
softAssertions.assertAll();
150+
142151
}
143152
public static void getException(){
144153
throw new RuntimeException();

0 commit comments

Comments
 (0)