Class OpenTest
java.lang.Object
cloud.opencode.base.test.OpenTest
Open Test
开放测试
Main facade for testing utilities.
测试工具的主要门面。
Features | 主要功能:
- Testing facade for assertions, mocks, benchmarks - 断言、模拟、基准测试的测试门面
- Zero-dependency test utilities - 零依赖测试工具
Usage Examples | 使用示例:
OpenTest.assertThat("hello").isNotBlank();
OpenTest.assertThat(42).isEqualTo(42);
UserService mock = OpenTest.mock(UserService.class).build();
Duration time = OpenTest.time(() -> heavyOperation());
Security | 安全性:
- Thread-safe: Yes (stateless) - 线程安全: 是(无状态)
- Since:
- JDK 25, opencode-base-test V1.0.0
- Author:
- Leon Soo www.LeonSoo.com
- See Also:
-
Method Summary
Modifier and TypeMethodDescriptionassertThat(Boolean actual) assertThat(Number actual) assertThat(String actual) static <T> OpenAssertions.CollectionAssertion<T> assertThat(Collection<T> actual) static <K,V> OpenAssertions.MapAssertion <K, V> assertThat(Map<K, V> actual) static <T> OpenAssertions.ObjectAssertion<T> assertThat(T actual) static voidassertThatCode(Runnable runnable) assertThatThrownBy(Runnable runnable) static Benchmark.BenchmarkResultstatic Benchmark.ComparisonResultstatic <T> MockBuilder<T> static <T> ToneOf(T... options) static <T> Tstatic booleanstatic byte[]randomBytes(int length) static doublestatic Stringstatic intrandomInt(int max) static intrandomInt(int min, int max) static Stringstatic Stringstatic StringrandomString(int length) static Spyspy()static Durationstatic <T> Benchmark.TimedResult<T> static Stringuuid()
-
Method Details
-
assertThat
-
assertThat
-
assertThat
-
assertThat
-
assertThat
-
assertThat
-
assertThatThrownBy
-
assertThatCode
-
mock
-
quickMock
-
spy
-
time
-
time
-
benchmark
-
compare
public static Benchmark.ComparisonResult compare(String name1, Runnable r1, String name2, Runnable r2) -
randomString
-
randomEmail
-
randomPhone
-
randomName
-
uuid
-
randomInt
public static int randomInt(int max) -
randomInt
public static int randomInt(int min, int max) -
randomDouble
public static double randomDouble() -
randomBoolean
public static boolean randomBoolean() -
randomBytes
public static byte[] randomBytes(int length) -
oneOf
-