Reputation: 6143
I have created UITesting like this. I need to run those 3 file in sequence and I need to name like this. I think it is quite bad. I want to name more logically (instead of Test1,etc). Is it possible to rename and run in sequence?
Another one is I need to name my method alphabetically. I want to name randomly and run in sequence. How shall I do?
- (void)test2CreatePost
- (void)test3ClickLikeInNewsfeed
Upvotes: 1
Views: 2078
Reputation: 1242
Functions nesting is fine for running UI tests from XCode instantly only. But when tests are running from command line, they are running by the alphabetic sequence. I've read that this issue was fixed for unit tests in XCode 8, but it seems not for UI tests.
For instance, now I have the following UI tests hierarchy:
UITests
TestCaseB
TestCaseA
When I run them from XCode 8.2.1 they are executed in the same sequence as they are described, i.e.:
TestCaseB
TestCaseA
But when I run them from command line using xcodebuild test TEST_TARGET_NAME=<TargetName> -scheme <UITestsSchemeName> destination 'platform=iOS Simulator,name=iPhone 7'
they are running in another sequence:
TestCaseA
TestCaseB
Be careful.
Upvotes: 3
Reputation: 9093
You could achieve this by nesting your functions.
// Note that this function contains tests but does not follow the 'testXXX' naming convention
func login() {
// Implement your test here
}
func newsfeed() {
// Implement your test here
}
func moreTab() {
// Implement your test here
}
// Here is the test method that will run the tests in a user-specified order
func testSomething() {
login()
newsfeed()
moreTab()
}
Upvotes: 1
Reputation: 129
You can use the procedure explained in this answer to achieve this.
Running individual XCTest (UI, Unit) test cases for iOS apps from the command line
Basically you need to override testInvocations present in XCTestCase, then you have control over the order of test case execution.
If you need more information on how to achieve this add a comment.
Upvotes: 0