Closed sochalewski closed 1 year ago
Hi @sochalewski, sorry to hear that you are facing this issue. We'll be happy to explore some options in making Braze.URLContext
more accessible for you. One alternative we could try is making the initializer for this struct public, so you would be able to initialize it with some mock values. Would this approach be appropriate for your testing?
This would help me a lot! 🙌
@sochalewski Thank you for your input! We'll keep you updated here.
Hi @sochalewski, just wanted to give an update that we've just released version 6.3.0 of the Braze Swift SDK, which exposes this initializer as public, so you should be able to create a Braze.URLContext
object from your end now.
Please let us know if you have any further questions. Thank you!
Thanks for solving the problem quickly! I've already restored my tests, everything works as expected. Have a good day!
What problem are you facing?
I successfully migrated from the old Objective-C SDK to the new one, but unfortunately I'm unable to cover with unit tests a class using
BrazeDelegate
functions.This is a very simple example, but it shows exactly what the problem is. In this case I can't write a unit test that executes
braze(_:shouldOpenURL:)
on the object, becauseBraze.URLContext
cannot be constructed.The previous SDK used
ABKURLDelegate
with the following signature:With this all parameters can be set to whatever you want making tests possible.
Workarounds
Not really as both
URLContext
(Swift) andBRZURLContext
(Objective-C) cannot be instantiated by hand.Ideal Solution
URLContext
a protocol instead of a classURLContext
(at least when#if DEBUG … #ENDIF
).Other Information
SDK: 6.2.0