我们建议您在对象从 Typhoon 发出之后为其创建集成测试。这些测试之一将是对象处于所需的初始状态:
@implementation MyTestCase
{
TyphoonBlockComponentFactory *_factory;
}
- (void)setUp
{
//Recommend putting this in a common place, so main test assembly only has to be set up once
_factory = [[TyphoonBlockComponentFactory alloc] initWithAssemblies:@[
[ApplicationAssembly assembly],
[CoreComponents assembly],
[PersistenceComponents assembly],
[NetworkComponents assembly]
]];
TyphoonConfigPostProcessor *postProcessor = [[TyphoonConfigPostProcessor alloc] init];
[postProcessor useResourceWithName:@"Config.plist"];
[factory attachPostProcessor:postProcessor];
}
//Assuming a classroom configured with a teacher count from Config.plist
- (void)test_classroom_should_initially_have_one_teacher
{
CoreComponents *components = [factory asAssembly];
ClassRoom *classRoom = [factory classroom];
XCTAssertEquals(1, classroom.numberOfTeachers);
}
. . . 从这里您可以继续为您的组件编写其他集成测试。
集成测试指南:
- 这是关于Typhoon 集成测试的指南。
- 您可以测试 TyphoonConfig 管道,但测试由程序集构建的对象侧重于需求 (BDD),并提供对程序集所有方面的隐式覆盖。