2015-07-21 81 views
3

剛學習。我在「ProjectNameTests」組中創建了一個類爲XCTestCase的子類。使用TDD在Swift中進行性能測試

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


     } 
    } 
} 

的性能測試,並想找出loop.I要去產品運行該項目的時間for的執行 - >執行動作 - >沒有建築物的測試。

我能看到的執行時間爲3.50秒,但是當我嘗試設置基線點擊中風區,如下圖:

enter image description here

我得到警告的是

你想對所有 設備的所有測試更新基線值?你將有機會,下次你 提交到源代碼控制,審查修改。現在

當我點擊更新誤差如下:

enter image description here

如何爲我的具體方法設定的時間基線Here

這裏是我的測試項目: https://drive.google.com/file/d/0Bzk4QVQhnqKmUzYyclp6ZnJvekE/view?usp=sharing

回答

1

您可以檢查BasicFunctionTest文件目標成員是否包含您的測試目標。您應該可以通過選擇文件並導航到File Inspector(目標成員資格)來檢查此項。

+0

感謝您的答覆....我雙重檢查吧.....和它做了......我已經上傳我的project..please看到我的問題 –

+0

奇怪,我只是想在同一步驟,並能更新基準。 – rshankar

+0

你只是試圖在演示項目,我已經建立?這些版本的Xcode您使用的是? –