java-tutorials/junit5/src/test/java/com/baeldung/AssumptionTest.java

33 lines
766 B
Java
Raw Normal View History

2016-04-15 23:47:32 +03:00
package com.baeldung;
import static org.junit.jupiter.api.Assertions.assertEquals;
import static org.junit.jupiter.api.Assumptions.assumeFalse;
import static org.junit.jupiter.api.Assumptions.assumeTrue;
import static org.junit.jupiter.api.Assumptions.assumingThat;
2016-04-15 23:47:32 +03:00
import org.junit.jupiter.api.Test;
2016-04-15 23:47:32 +03:00
public class AssumptionTest {
@Test
void trueAssumption() {
assumeTrue(5 > 1);
2016-05-02 13:00:21 +03:00
assertEquals(5 + 2, 7);
2016-04-15 23:47:32 +03:00
}
@Test
void falseAssumption() {
assumeFalse(5 < 1);
2016-05-02 13:00:21 +03:00
assertEquals(5 + 2, 7);
2016-04-15 23:47:32 +03:00
}
@Test
void assumptionThat() {
String someString = "Just a string";
assumingThat(
someString.equals("Just a string"),
2016-05-02 13:00:21 +03:00
() -> assertEquals(2 + 2, 4)
2016-04-15 23:47:32 +03:00
);
}
}