- Added code for JUnit 5 article
This commit is contained in:
27
junit5/src/test/java/com/baeldung/FirstTest.java
Normal file
27
junit5/src/test/java/com/baeldung/FirstTest.java
Normal file
@@ -0,0 +1,27 @@
|
||||
package com.baeldung;
|
||||
|
||||
import org.junit.gen5.api.Test;
|
||||
|
||||
import static org.junit.gen5.api.Assertions.assertAll;
|
||||
import static org.junit.gen5.api.Assertions.assertEquals;
|
||||
import static org.junit.gen5.api.Assertions.assertTrue;
|
||||
|
||||
class FirstTest {
|
||||
|
||||
@Test
|
||||
void lambdaExpressions() {
|
||||
String string = "";
|
||||
assertTrue(() -> string.isEmpty(), "String should be empty");
|
||||
}
|
||||
|
||||
@Test
|
||||
void groupAssertions() {
|
||||
int[] numbers = {0,1,2,3,4};
|
||||
assertAll("numbers", () -> {
|
||||
assertEquals(numbers[0], 1);
|
||||
assertEquals(numbers[3], 3);
|
||||
assertEquals(numbers[4], 1);
|
||||
});
|
||||
}
|
||||
|
||||
}
|
||||
Reference in New Issue
Block a user