Performance testing in Swift using TDD

时光毁灭记忆、已成空白 提交于 2019-11-27 08:04:57

问题


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


        }
    }
}

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.

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:

I get warning as as

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.

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

Here is my test project : https://drive.google.com/file/d/0Bzk4QVQhnqKmUzYyclp6ZnJvekE/view?usp=sharing


回答1:


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



来源:https://stackoverflow.com/questions/31534903/performance-testing-in-swift-using-tdd

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!