I need to do the pre-test config, one time setup before I run XCUITest (automation test) cases,
Example of pre-test setup: (This needs to be done once for test cycle, the output of below APIs is used in all test cases)
qTest
access tokenqTest
URLs from remote config file.From docs I found that testBundleWillStart
method of XCTestObservation
protocol is ideal place to do pre-test setup.
But
-testBundleWillStart
method is not getting called or executed,
all below listed methods of XCTestObservation
are getting executed correctly.
testSuiteWillStart
testCaseWillStart
testCaseDidFinish
testSuiteDidFinish
I tried setting Principal Class
in UITest info.plist
but no luck, it shows following error
Test bundle Info.plist at /var/containers/Bundle/Application/BEAFB0C2-43D5-4C90-B50F-B1FF1A16BC23/MyAppUITests-Runner.app/PlugIns/MyAppUITests.xctest/Info.plist specified MyAppUItests.TestObserver for NSPrincipalClass, but no class matching that name was found.
How can I get the method testBundleWillStart
executed?
Any help would be appreciated.
Found the issue,
My project name had a space, so replacing the space with _
worked.
Info about my project:
My App
My-AppUITests
Working Solution: (Replacing space with _
character)
<key>NSPrincipalClass</key>
<string>My_AppUITests.SOTestObserver</string>
Let me also share the things that seem right but still don't work:
Non-working #1: (Replacing space with -
character)
<key>NSPrincipalClass</key>
<string>My-AppUITests.SOTestObserver</string> //Didn't work
Non-working #2: (Replacing project name with $(PRODUCT_NAME)
environment variable)
<key>NSPrincipalClass</key>
<string>$(PRODUCT_NAME).SOTestObserver</string> //Didn't work