Tag: tdd

如何加快iOS和Objective-C / Xcode的TDDstream量

在Objective-C和iOS开发中一直在寻找TDD的经验。 以前的post关于“string计算器”在Objective-C中的数据是有用的(谢谢)。 但是学习更stream畅的iPhone-TDD将是一件好事。 你有一些如何使用UISpec (基于Rspec ), iCuke (基于黄瓜 )或类似的工具的经验? 而且,如果你也像保罗在他的博客中那样得到了自动testing(autoiphonetest.rb)的stream程,这将是非常有趣的反馈。 这是一个很好的文章: 用MacRuby在Objective-C中进行testing驱动开发

如何用共同的逻辑testing2种方法?

假设我有两个公共方法: func didSelect(data: Data) { // do something self.view.showText(textForData(data)) } func didDismiss(data: Data) { if data.isSomething { self.view.showText(textForData(data)) } … } private func textForData(data: Data): String { var text: String if data.distance == nil { text = "…" } else if data.distance < 1000 { text = "\(data.distance) m" } else { text = "\(data.distance […]

视图控制器TDD

我正在尝试添加一些unit testing到我的项目来testing视图控制器。 但是,我似乎有看似简单的事情有问题。 我已经创build了一个我将参考的示例项目。 https://github.com/pangers/ViewControllerTesting 该示例包含一个UINavigationController作为初始视图控制器。 UINavigationController的根视图控制器是FirstViewController。 FirstViewController上有一个button,可以连接到SecondViewController。 在SecondViewController中有一个空的文本字段。 我试图添加的两个testing是: 1)检查FirstViewController中的button标题是“下一个屏幕”。 2)检查SecondViewController中的文本字段为空,“”。 我听说有关将swift文件添加到主目标和testing目标的报告不是很好的做法。 而是在你的公共testing中做任何你想要访问的东西,并把主要目标导入到testing中。 这就是我所做的。 (我也把主要目标的“定义模块”设置为YES,就像我在几篇文章中所读到的那样)。 在FirstViewControllerTests我已经实例化第一个视图控制器与以下内容: var viewController: FirstViewController! override func setUp() { let storyboard = UIStoryboard(name: "Main", bundle: NSBundle(forClass: self.dynamicType)) let navigationController = storyboard.instantiateInitialViewController() as UINavigationController viewController = navigationController.topViewController as FirstViewController viewController.viewDidLoad() } 我已经添加了testing: func testCheckButtonHasTextNextScreen() { XCTAssertEqual(viewController.button.currentTitle!, "Next Screen", "Button should say […]

使用TDD在Swift中进行性能testing

在Swift学习Test Driven Development 。我在“ProjectNameTests”组中创build了一个XCTestCase子类。 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 […]