Assert新增断言给定集合为空的方法以及单元测试用例

This commit is contained in:
baofeidyz
2025-05-29 11:19:01 +08:00
parent 420e54a37d
commit 5b10fedfef
2 changed files with 74 additions and 0 deletions

View File

@@ -4,6 +4,9 @@ import cn.hutool.core.util.StrUtil;
import org.junit.jupiter.api.Assertions;
import org.junit.jupiter.api.Test;
import java.util.ArrayList;
import java.util.List;
public class AssertTest {
@Test
@@ -68,4 +71,13 @@ public class AssertTest {
}
@Test
public void emptyCollectionTest() {
List<Object> testList = new ArrayList<>();
Assertions.assertDoesNotThrow(() -> Assert.empty(null));
Assertions.assertDoesNotThrow(() -> Assert.empty(testList));
testList.add(new Object());
Assertions.assertThrows(IllegalArgumentException.class, () -> Assert.empty(testList));
}
}