gpt4 book ai didi

ios - 使用 TDD 在 Swift 中进行性能测试

转载 作者:搜寻专家 更新时间:2023-10-31 23:02:48 24 4
gpt4 key购买 nike

刚刚学习 Swift 中的测试驱动开发。我在“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 循环的时间。我运行项目,转到 Product -> Perform Action -> Test Without Building。

我可以看到执行时间为 3.50 秒,但是当我尝试设置基线时,请点击描边区域,如下图所示:

enter image description here

我收到警告

Would you like to update the baseline values for all tests on all devices? You'll have a chance to review the changes the next time you commit to source control.

现在当我点击更新时,错误如下:

enter image description here

如何将我的特定方法的时间基线设置为 Here

这是我的测试项目: https://drive.google.com/file/d/0Bzk4QVQhnqKmUzYyclp6ZnJvekE/view?usp=sharing

最佳答案

您能否检查 BasicFunctionTest 文件 Target 成员资格是否包括您的测试目标。您应该能够通过选择文件并导航到文件检查器(目标成员资格)来检查这一点。

关于ios - 使用 TDD 在 Swift 中进行性能测试,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/31534903/

24 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com