Group Group Group Group Group Group Group Group Group

SFSafariViewController + Testing [Firebase Crashlytics]

Post looking at the stack trace, I now check existence of http or https via the following

if ["http", "https"].contains(url.scheme?.lowercased() ?? "") {
  log.info("Can open with SFSafariViewController")
  let safariViewController = SFSafariViewController(url: url)
  self.present(safariViewController, animated: true, completion: nil)
} else {
  log.info("If scheme is not supported or no scheme is given, use openURL")
  UIApplication.shared.open(url, options: [:], completionHandler: nil)
}

How do I go about writing a test for this? Or how do I even go about testing this in any which way? It doesn’t crash on the simulator or the device I own

Hi @lganti,
You are testing the scheme but you are missing the most obvious that is, Is the URL correct? so your test can try to first check if the url is not empty and then if it is correct and not malformed.

I am not sure about what your app is trying to do, so that’s all I can think of for now

cheers,

1 Like

Thanks for the response, Jayant

I do check for the existence of a URL before I test the scheme, shall add the checking for a valid part