You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Say I have an application with two assemblies: FooAssembly and BarAssembly. BarAssembly actually makes use of FooAssembly, so FooAssembly shouldn't know anything about BarAssembly.
In FooAssembly I declare a component called foo. foo has a fooExternalInterface property of type id <FooExternalInterface>. This is injected by type:
// FooAssembly.m
- (Foo *)foo {
return [TyphoonDefinition withClass:[Foo class] configuration:^(TyphoonDefinition *definition) {
[definition injectProperty:@selector(fooExternalInterface)];
}];
}
// NB: no component called `fooExternalInterface` is declared in `FooAssembly`.
Let's say in BarAssembly we have a component bar that conforms to FooExternalInterface. When the application is put together, this dependency gets resolved. Happy days. This is a powerful technique for isolating assemblies from one another.
Now, let's say I want to write an integration test for FooAssembly only, following the guide over at https://github.com/appsquickly/typhoon/wiki/integration-testing. I only activate FooAssembly. In the absence of BarAssembly, Typhoon complains that there's no instances match the type id <FooExternalInterface>.
Well... okay, how can I inject a test double for this interface then? I refuse to have my test initialise BarAssembly.
Do I need to declare a BarTestAssembly that declare a test component? Nah, that's too much effort — it's a lot of code just to perform an injection.
... but this is still not idea, because I just want to supply a OCMock object directly, so that I can verify interactions against it. I tried TyphoonDefinition's with:; it didn't work with injection by type.
Well, I thought TyphoonPatcher would be perfect for this — but there's a problem: fooExternalInterface is not a component that can be patched out in FooAssembly.
I really really wish I could say to the patcher, "Hey, please take this mock object, and resolve to it whenever you get asked about id <FooExternalInterface> when injecting by type. K thxbye!" that would be grand.
Say I have an application with two assemblies:
FooAssembly
andBarAssembly
.BarAssembly
actually makes use ofFooAssembly
, soFooAssembly
shouldn't know anything aboutBarAssembly
.In
FooAssembly
I declare a component calledfoo
.foo
has afooExternalInterface
property of typeid <FooExternalInterface>
. This is injected by type:Let's say in
BarAssembly
we have a componentbar
that conforms toFooExternalInterface
. When the application is put together, this dependency gets resolved. Happy days. This is a powerful technique for isolating assemblies from one another.Now, let's say I want to write an integration test for
FooAssembly
only, following the guide over at https://github.com/appsquickly/typhoon/wiki/integration-testing. I only activateFooAssembly
. In the absence ofBarAssembly
, Typhoon complains that there'sno instances match the type id <FooExternalInterface>
.Well... okay, how can I inject a test double for this interface then? I refuse to have my test initialise
BarAssembly
.Do I need to declare a
BarTestAssembly
that declare a test component? Nah, that's too much effort — it's a lot of code just to perform an injection.So far, I came up with this solution:
... but this is still not idea, because I just want to supply a
OCMock
object directly, so that I can verify interactions against it. I tried TyphoonDefinition'swith:
; it didn't work with injection by type.Well, I thought
TyphoonPatcher
would be perfect for this — but there's a problem:fooExternalInterface
is not a component that can be patched out inFooAssembly
.I really really wish I could say to the patcher, "Hey, please take this mock object, and resolve to it whenever you get asked about
id <FooExternalInterface>
when injecting by type. K thxbye!" that would be grand.@jasperblues Any thoughts?
The text was updated successfully, but these errors were encountered: