Share Extension UI Tests written in Swift – onlinecode
In this post we will give you information about Share Extension UI Tests written in Swift – onlinecode. Hear we will give you detail about Share Extension UI Tests written in Swift – onlinecodeAnd how to use it also give you demo for it if it is necessary.
UI Tests are a great tool to validate your application. It is easy to create them for your main application, but it might be harder to create a UI test for your share extension. This can be just as easy as your main application with some simple steps.
A UI test for testing the extension needs a few extra steps.
- Launch an external app, for example, Safari
- Navigate to some sharable content
- Open the share sheet
- Enable the extension for your application
- Open the extension for your application
After that, you should be able to interact with your extension.
To make this really easy, I’ve written an extension which can be found here: https://gist.github.com/AvdLee/719b2de80d74fc503ca1c64a23706d93.
This results in just a few lines of code before you can start interacting with your share extension:
// start main app to make sure the Share Extension exists.
let mainApp = XCUIApplication()
mainApp.launch()
let safariApp = openSafari(with: URL(string: "https://www.onlinecode.org")!)
openShareExtension(name: "Example Share Extension", in: safariApp)
This video will show you how a certain UI Test run would look:
This video is directly recorded from the simulator using simctl. Read more about it here.
Hope this code and post will helped you for implement Share Extension UI Tests written in Swift – onlinecode. if you need any help or any feedback give it in comment section or you have good idea about this post you can give it comment section. Your comment will help us for help you more and improve us. we will give you this type of more interesting post in featured also so, For more interesting post and code Keep reading our blogs