I have problem with TyphoonPatcher used in Integration Tests. I'm using KIF for integration tests. Sometimes i need to stub http client or class responsible for saving data in database. The easiest way is use TyphoonPatcher.
Lets say that i need patch patch knight to stubbed knight for TestCase A, for all test cases, so i'm doing this in beforeAll callback
code responsible for patching component:
MiddleAgesAssembly* assembly = [[MiddleAgesAssembly assembly] activate];
TyphoonPatcher* patcher = [[TyphoonPatcher alloc] init];
[patcher patchDefinitionWithSelector:@selector(knight) withObject:^id{
Knight* mockKnight = mock([Knight class]);
[given([mockKnight favoriteDamsels]) willReturn:@[
@"Mary",
@"Janezzz"
]];
return mockKnight;
}];
[assembly attachPostProcessor:patcher];
Knight* knight = [(MiddleAgesAssembly*) factory knight]
And now in TestCase B i want to have clear state of app, without any patched componenets.
Problem? Knight in class B is still replaced with other mocked or stubbed class.
Is there any way to revert patch from TestCase A?