Home > Back-end >  Write UITest inside a framework
Write UITest inside a framework

Time:03-07

Is it possible to write UITest for a swift framework?

I have a framework with lots of UI components and I want to write some UITest for it but since that we can't run a framework (or I don't know how to do it) I can't write UITest for it.

Thanks for your helps.

CodePudding user response:

I didn't find it stated explicitly, but UI testing in XCTest requires a running app. So, I suppose the answer is "no".

"UI testing works by finding an app’s UI objects with queries, synthesizing events and sending them to those objects, and providing a rich api enabling you to examine the UI objects properties and state to compare them against the expected state." (https://developer.apple.com/library/archive/documentation/DeveloperTools/Conceptual/testing_with_xcode/chapters/09-ui_testing.html)

"A UI element in an application." (https://developer.apple.com/documentation/xctest/xcuielement)

However, you can always adopt unit testing for your needs: UI elements can be instantiated and provided with frames without adding them to an app's view hierarchy.

  • Related