mirror of
https://gitee.com/chinabugotech/hutool.git
synced 2025-07-21 15:09:48 +08:00
单元测试由Junit4变更为Junit5
This commit is contained in:
@@ -1,9 +1,11 @@
|
||||
package cn.hutool.cron.pattern;
|
||||
|
||||
import cn.hutool.cron.CronException;
|
||||
import static org.junit.jupiter.api.Assertions.*;
|
||||
import org.junit.jupiter.api.Test;
|
||||
|
||||
import static org.junit.jupiter.api.Assertions.assertEquals;
|
||||
import static org.junit.jupiter.api.Assertions.assertThrows;
|
||||
|
||||
public class CronPatternBuilderTest {
|
||||
|
||||
@Test
|
||||
@@ -32,13 +34,15 @@ public class CronPatternBuilderTest {
|
||||
assertEquals("* * 2-9 * * *", build);
|
||||
}
|
||||
|
||||
@Test(expected = CronException.class)
|
||||
@Test
|
||||
public void buildRangeErrorTest(){
|
||||
String build = CronPatternBuilder.of()
|
||||
assertThrows(CronException.class, () -> {
|
||||
String build = CronPatternBuilder.of()
|
||||
.set(Part.SECOND, "*")
|
||||
// 55无效值
|
||||
.setRange(Part.HOUR, 2, 55)
|
||||
.build();
|
||||
assertEquals("* * 2-9 * * *", build);
|
||||
assertEquals("* * 2-9 * * *", build);
|
||||
});
|
||||
}
|
||||
}
|
||||
|
@@ -2,9 +2,11 @@ package cn.hutool.cron.pattern;
|
||||
|
||||
import cn.hutool.core.date.DateUtil;
|
||||
import cn.hutool.cron.CronException;
|
||||
import static org.junit.jupiter.api.Assertions.*;
|
||||
import org.junit.jupiter.api.Test;
|
||||
|
||||
import static org.junit.jupiter.api.Assertions.assertThrows;
|
||||
import static org.junit.jupiter.api.Assertions.assertTrue;
|
||||
|
||||
/**
|
||||
* 定时任务单元测试类
|
||||
*
|
||||
@@ -159,10 +161,12 @@ public class CronPatternTest {
|
||||
assertMatch(pattern, "2017-12-02 23:59:59");
|
||||
}
|
||||
|
||||
@Test(expected = CronException.class)
|
||||
@Test
|
||||
public void rangeYearTest() {
|
||||
// year的范围是1970~2099年,超出报错
|
||||
CronPattern.of("0/1 * * * 1/1 ? 2020-2120");
|
||||
assertThrows(CronException.class, () -> {
|
||||
// year的范围是1970~2099年,超出报错
|
||||
CronPattern.of("0/1 * * * 1/1 ? 2020-2120");
|
||||
});
|
||||
}
|
||||
|
||||
/**
|
||||
|
@@ -5,7 +5,7 @@ import org.junit.jupiter.api.Test;
|
||||
|
||||
import java.util.Date;
|
||||
|
||||
import static org.junit.Assert.assertEquals;
|
||||
import static org.junit.jupiter.api.Assertions.assertEquals;
|
||||
|
||||
public class Issue3685Test {
|
||||
@Test
|
||||
|
Reference in New Issue
Block a user