使用TDD在Swift中进行性能测试 [英] Performance testing in Swift using TDD

查看:146
本文介绍了使用TDD在Swift中进行性能测试的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

Swift 中学习测试驱动开发。我创建了一个类,它是 XCTestCase 。

Just learning Test Driven Development in Swift.I created a class that is subclass of XCTestCase in the "ProjectNameTests" group.

    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")


                }
            }
        }
}

我想对这些进行性能测试方法

I want to perform performance testing of these method

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")


        }
    }
}

并想知道执行<$的时间c $ c> for loop.I在转到Product - > Perform Action - > Test Without Building时运行项目。

and want to find out the time for execution of the for loop.I run the project on going to Product -> Perform Action - > Test Without Building.

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

I can see the execution time as 3.50 sec but when i try to set the baseline clicking on the Stroke Area as below image:

我收到警告


您是否要更新所有
设备上所有测试的基线值?您将有机会在下次
提交源代码控制时查看更改。

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.

现在点击on更新错误如下:

Now when i click on Update the error is as below:

如何为我的特定方法设置基线时间这里

How can i set Baseline of the time for my specific method as Here

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

推荐答案

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

Can you check whether BasicFunctionTest file Target membership includes your test target. You should be able to check this by selecting the file and navigating to File Inspector (target membership).

这篇关于使用TDD在Swift中进行性能测试的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆