Replies: 1 comment 1 reply
-
|
That's a great question, and you outlined the current considerations and tradeoffs very well. I unfortunately don't have a great solution to dependency injection for you, but I'll add that the testing limitations do vary depending on what mode you are using Skip in. Skip Lite (transpiled)As you point out (and as mentioned in our testing docs), Skip Lite currently only supports legacy XCTest style test cases, and not the newer Testing framework. This could be something we enhance in the future, but we'll be fairly limited by the fact that Skip's transpilation doesn't support macros, which the Testing framework uses heavily. XCTest, OTOH, can convert to Android JUnit tests in a fairly straightforward way. In pure Skip Lite mode, you would probably have to come up with your own dependency injection solution; we would be interested in collaborating on something that could be used by the wider community if you have any ideas you would like the share about the best way to implement it. Skip Fuse (compiled)Compiled (Fuse) mode is a different story. By default, a compiled package created will Skip will still use transpiled mode for the testing, and set up the module to enable bridging. This can actually be useful for testing out the Swift-to-Kotlin bridging side of your project (in case that is something you are using), but still suffers from the limitations that transpiled testing is limited to XCTest-style test cases. Take a look at https://github.com/skiptools/skip-bridge/tree/main/Tests for some of the variations of testing that can be accomplished with native modules + transpiled testing. Native Android TestingHowever, if the module you are testing is a pure-native module and doesn't require any Java/Kotlin bridging, then you could simply use native SwiftPM testing along with the Testing framework, rather than Skip's test harness. Skip supports running these kinds of tests on your Android device or emulator using The downside to this mode is that Hopefully this provides a bit more clarity to the landscape of cross-platform testing with Skip. We'd love to chat more about this, since testing is a passion of ours 😊 |
Beta Was this translation helpful? Give feedback.
Uh oh!
There was an error while loading. Please reload this page.
-
In a pure (modern) Xcode project, on would write Swift Tests or XCTests suites with injected mock dependencies using a dependency-injection library like swift-dependencies to avoid unwanted side effects (hitting servers...) + provide consistency + control the scope of the test.
When unit-testing native skip modules
This approach isn't an option because the XCTest suite is transpiled, and no dependency-injection library will travel across transpiled / native boundaries.
Possible workaround strategies:
When unit-testing transpiled modules,
The modern approach is not an option either because I am not aware of a transpiled dependency-injection library
Possible workaround strategies:
Question
Has anyone figured out the a strategy mix that works for them? (we just started a new project and would like to nail the unit-testing early if we can)
Beta Was this translation helpful? Give feedback.
All reactions