Тестирование производительности в Swift с использованием TDD
Только учитсяTest Driven Development
вSwift
.I создал класс, который является подклассомXCTestCase
в группе "ProjectNameTests".
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 с, но когда я пытаюсь установить базовую линию, нажимая на область обводки, как показано на рисунке ниже:
Я получаю предупреждение как
Хотите обновить базовые значения для всех тестов на всех устройствах? У вас будет возможность просмотреть изменения в следующий раз, когда вы перейдете к исходному контролю.
Теперь, когда я нажимаю на Обновить, ошибка выглядит так:
Как я могу установить базовое время для моего конкретного метода какВот
Вот мой тестовый проект:https://drive.google.com/file/d/0Bzk4QVQhnqKmUzYyclp6ZnJvekE/view?usp=sharing