-
-
Notifications
You must be signed in to change notification settings - Fork 1.6k
Description
Steps to reproduce
import org.junit.jupiter.api.AfterEach;
import org.junit.jupiter.api.Test;
import static org.junit.jupiter.api.Assertions.fail;
import static org.junit.jupiter.api.Assumptions.assumeTrue;
public class PostFactoAssumptionsTest {
@AfterEach
public void tearDown() {
assumeTrue(false);
}
@Test
public void testAssumptions() {
fail();
}
}Expected Behavior: Test Ignored
Actual Behavior: Test Failed
Context
- Used versions (Jupiter/Vintage/Platform): 5.10.3
- Build Tool/IDE: IntelliJ, Maven
What I'm trying to do
import org.junit.jupiter.api.AfterEach;
import org.junit.jupiter.api.BeforeEach;
import org.junit.jupiter.api.Test;
import java.time.Duration;
import java.time.LocalDate;
import java.time.LocalDateTime;
import java.util.List;
import static org.junit.jupiter.api.Assumptions.assumeTrue;
@UseH2
public class GetByAgeTest {
LocalDateTime NOW = LocalDateTime.now();
MyService service = new MyService();
@BeforeEach
public void setUp() {
insertRowIntoDb(1, NOW);
insertRowIntoDb(2, NOW.minusDays(1));
}
@AfterEach
public void tearDown() {
boolean dateDidntIncrementDuringTestRun = NOW.toLocalDate().equals(LocalDate.now());
assumeTrue(dateDidntIncrementDuringTestRun);
}
@Test
public void testGetByAge() {
var results = service.getNewerThan(Duration.ofDays(1));
assertThat(results).hasSize(1);
}
}
public class MyService {
public List<MyEntity> getNewerThan(Duration duration) {
return queryDb("""
SELECT *
FROM my_table
WHERE dateCol > trunc(now()) - ?
""", duration.toDays());
}
}