I am having trouble testing a UIAlertController being presented. I saw a guide on this (https://swiftandpainless.com/how-to-test-uialertcontroller-in-swift/) but it still doesn't work because any time I test if a view controller is presented it returns nil
. I am wondering if my issue is that the current VC I am testing is a presented VC itself.
describe("showLogOutAlert is called") {
context("logOut alert is called and cancel is selected"){
it("should be presented then dismissed") {
sut.showLogOutAlert()
expect(sut.presentedViewController).to(beAKindOf(UIAlertController.self))
}
}
}
I would like to test if buttons are selected as well but I can't get passed the first part of testing if a view controller is presented. This is an issue I'm having with anything I'm trying to test being presented (i.e. MailComposeViewController).
Note: yes these are actually being presented when I run the application so the test isn't correct in calling it nil
.
Aucun commentaire:
Enregistrer un commentaire