【发布时间】:2018-08-03 12:57:19
【问题描述】:
我在使用 XCTest 框架为 IOS 编写 UI 测试用例时遇到问题。
考虑一个 3 步注册过程和每个步骤的 3 个测试用例。并且为了运行每个测试用例,它需要用户退出。所以,我把代码写成
test1(){
//some code here for step 1
}
test2(){
test1()
//some code here for step 2
}
test3(){
test2()
//some code here for step 3
}
这在单独运行测试用例时效果很好。但是集体运行时,第一个测试运行成功,第二个测试失败,因为它要求注册用户在运行文本之前注销。 现在为了解决这个问题,我编写代码如下:
test1(){
//some code here for step 1
//logout code
}
test2(){
test1()
//some code here for step 2
//logout code
}
test3(){
test2()
//some code here for step 3
//logout code
}
现在的问题是,在运行第二个测试用例时,它调用了第一个注销用户的函数,我们无法重用代码。 有更好的方法吗?
【问题讨论】:
标签: xctest xcode-ui-testing ios-ui-automation