【发布时间】:2015-10-10 15:53:33
【问题描述】:
刚刚在Swift 中学习Test Driven Development。我在“ProjectNameTests”组中创建了一个属于XCTestCase 的子类的类。
class BasicFunctionTest: XCTestCase {
var values : [Int]?
override func setUp() {
super.setUp()
// Put setup code here. This method is called before the invocation of each test method in the class.
}
override func tearDown() {
// Put teardown code here. This method is called after the invocation of each test method in the class.
super.tearDown()
}
func testExample() {
// This is an example of a functional test case.
XCTAssert(true, "Pass")
}
func testPerformanceExample() {
// This is an example of a performance test case.
self.measureBlock() {
// Put the code you want to measure the time of here.
for i in 1...100000{
println("ok i need to know the time for execution")
}
}
}
}
我想对这些方法进行性能测试
func testPerformanceExample() {
// This is an example of a performance test case.
self.measureBlock() {
// Put the code you want to measure the time of here.
for i in 1...100000{
println("ok i need to know the time for execution")
}
}
}
并想找出执行for 循环的时间。我在转到产品-> 执行操作-> 测试而不构建时运行项目。
我可以看到执行时间为 3.50 秒,但是当我尝试设置基线时,单击描边区域,如下图所示:
我收到警告
您想更新所有测试的基线值吗? 设备?下次您将有机会查看更改 致力于源代码管理。
现在当我点击更新时,错误如下:
如何将我的具体方法的时间基线设置为Here
这是我的测试项目: https://drive.google.com/file/d/0Bzk4QVQhnqKmUzYyclp6ZnJvekE/view?usp=sharing
【问题讨论】:
标签: ios swift testing tdd performance-testing