Class TestFixture<T>
java.lang.Object
cloud.opencode.base.test.fixture.TestFixture<T>
- Type Parameters:
T- the fixture data type | 夹具数据类型
Test Fixture
测试夹具
A reusable test fixture that can be set up and torn down.
可重用的测试夹具,可以设置和拆除。
Features | 主要功能:
- Reusable test data fixtures - 可重用的测试数据夹具
- Setup and teardown lifecycle - 设置和拆卸生命周期
Usage Examples | 使用示例:
TestFixture<User> fixture = TestFixture.of(() -> new User("test"));
User user = fixture.get();
Security | 安全性:
- Thread-safe: No - 线程安全: 否
- Since:
- JDK 25, opencode-base-test V1.0.0
- Author:
- Leon Soo www.LeonSoo.com
- See Also:
-
Nested Class Summary
Nested ClassesModifier and TypeClassDescriptionstatic classBuilder for TestFixture TestFixture的构建器 -
Constructor Summary
ConstructorsConstructorDescriptionTestFixture(String name, Supplier<T> setup) Create test fixture 创建测试夹具Create test fixture with teardown 创建带拆除的测试夹具 -
Method Summary
Modifier and TypeMethodDescriptionstatic <T> TestFixture.Builder<T> Create fixture builder 创建夹具构建器get()Get the fixture data (alias for setUp) 获取夹具数据(setUp的别名)getName()Get fixture name 获取夹具名称booleanCheck if initialized 检查是否已初始化voidreset()Reset the fixture 重置夹具setUp()Set up the fixture 设置夹具voidtearDown()Tear down the fixture 拆除夹具
-
Constructor Details
-
TestFixture
-
TestFixture
-
-
Method Details
-
builder
Create fixture builder 创建夹具构建器- Type Parameters:
T- the data type | 数据类型- Parameters:
name- the fixture name | 夹具名称- Returns:
- the builder | 构建器
-
getName
-
setUp
-
get
Get the fixture data (alias for setUp) 获取夹具数据(setUp的别名)- Returns:
- the fixture data | 夹具数据
-
tearDown
public void tearDown()Tear down the fixture 拆除夹具 -
isInitialized
public boolean isInitialized()Check if initialized 检查是否已初始化- Returns:
- true if initialized | 如果已初始化返回true
-
reset
public void reset()Reset the fixture 重置夹具
-