我正在为我公司的网站编写自动化测试,现在我也在为 iOS 应用程序编写测试。在我使用 javascript 进行的 Jasmine 测试中,我使用 .forEach()
循环来创建测试模板,例如:
[one, two].forEach(function(number){
it('should print ' + number, function() {
console.log(number);
}
});
// Output:
// 'should print one' #=> one
// 'should print two' #=> two
有什么方法可以在 XCTest
中用 Swift 做到这一点吗?
最佳答案
Swift 有 for-in 循环:
let inputs = ["abc", "def", "ghi"]
for input in inputs {
// do something
print(input)
// assert something
XCTAssertTrue(someFunc(input))
}
关于javascript - 尝试在 XCTest 中进行模板测试,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/41671186/