How to instantiate SBDGroupChannel with JSON for unit testing?

For unit testing purposes I need to instantiate mock SBDGroupChannel. I’ve taken the JSON structure of a channel from Charles and I’m using this JSON to create a Data which I’d like to use building the channel.

func mockGroupChannel() -> SBDGroupChannel? {
        let bundle = Bundle(for: type(of: self))
        guard let url = bundle.url(forResource: "messaging_channel", withExtension: "json"),
              let groupChannelData = try? Data(contentsOf: url, options: .mappedIfSafe) else {
            return nil
        let groupChannel = groupChannelData)
        return groupChannel

But the SBDGroupChannel object is always nil.

Could you please provide a correct JSON file which I could use to instantiate the Data expected by the build(fromSerializedData:) method.


Hi @D-Integral,

Welcome to the Sendbird Community. This looks to be in line with this topic: How to mock SBDGroupChannel?

Let me connect with the team to see what we can do.

1 Like

Hi @Tyler ,

Yes, I’ve seen that topic, but it doesn’t contain the answer, and we still are unable to find the expected new method initWithDictionary inside the last version of the SDK…

1 Like

They’ve not yet been opened. That discussion is still ongoing, which is why you cannot find them. I’ll bring this back up to the team to see if we have an update.


1 Like

Thank you, @Tyler ,

I will wait for the update.

1 Like

@D-Integral, Woo mentioned it looks like those methods will be released soon: How to mock SBDGroupChannel? - #8 by Woo

1 Like

Hi @Tyler, thanks for adding init for SBDGroupChannel! Now we continue writing unit tests for the messaging feature and would like to ask you is it possible to open init for SBDBaseMessage?

1 Like

I’m little concerned about this. Because internally property mapping is not always as it is (for instance, naming isSuper is not necessary to be mapped from isSuper or is_super) due to legacy and backward compatibility. Btw, initWithDictionary on BaseMessage is exposed.

1 Like

Hi @Woo. Yes, you’re right. It’s there. It was my mistake. I was looking for it in the documentation (here - SBDBaseMessage Class Reference) and it seems like it’s not documented. But now I see that it’s exposed: for Swift - SBDBaseMessage(dictionary: dictionary). Thank you sо much for your help!