Welcome to OGeek Q&A Community for programmer and developer-Open, Learning and Share
Welcome To Ask or Share your Answers For Others

Categories

0 votes
248 views
in Technique[技术] by (71.8m points)

ios - Performance testing in Swift using TDD

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:

enter image description here

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:

enter image description here

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

See Question&Answers more detail:os

与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
Welcome To Ask or Share your Answers For Others

1 Reply

0 votes
by (71.8m points)

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


与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
OGeek|极客中国-欢迎来到极客的世界,一个免费开放的程序员编程交流平台!开放,进步,分享!让技术改变生活,让极客改变未来! Welcome to OGeek Q&A Community for programmer and developer-Open, Learning and Share
Click Here to Ask a Question

...