We are used to the test driven develop way.When i move to develop objective-c,i need write testcase too.
Finally I found some useful article (http://developer.apple.com/mac/articles/tools/unittestingwithxcode3.html).
1: Set up a Cocoa project follow the instructions.
2:New a target named TestCase
3: set testcase run path: Test Host and Bundle Loader
$(BUILT_PRODUCTS_DIR)/OCT.app/Contents/MacOS/OCT
4: select testcase and then build and run
Aslo there are some useful Assert wealthy to be remmenberd
OCUnit Macro
Purpose
STAssertNil(a1, description, ...) |
Generates an error if a1 is not nil. |
STAssertNotNil(a1, description, ...) |
Generates an error if a1 is nil. |
STAssertTrue(expression, description, ...) |
Generates an error if expression does not evaluate to true |
STAssertFalse(expression, description, ...) |
Generates an error if expression does not evaluate to false |
STAssertEqualObjects(a1, a2, description, ...) |
Generates an error if a1 is not equal to a2. Both must be Objective-C objects. |
STAssertEquals(a1, a2, description, ...) |
Generates an error if a1 is not equal to a2. Both must be C scalar values. |
STAssertEqualsWithAccuracy(left, right, accuracy, description, ...) |
Generates an error if a1 and a2 are not within a certain amount of each other. Primarily for use with floats and doubles to take into account small rounding errors due to the way they store values. |
STAssertThrows(expression, description, ...) |
Generates an error if expression does not throw an exception. |
STAssertThrowsSpecific(expression, specificException, description, ...) |
Generates an error if expression does not throw an exception of a specified class. |
STAssertThrowsSpecificNamed(expr, specificException, aName, description, ...) |
Generates an error if expression doesn’t throw an exception with a specific name. |
STAssertNoThrow(expression, description, ...) |
Generates an error if expression throws an exception. |
STAssertNoThrowSpecific(expression, specificException, description, ...) |
Generates an error if expression throws an exception of a specified class. |
STAssertNoThrowSpecificNamed(expr, specificException, aName, description, ...) |
Generates an error if expression throws an exception with a specific name. |
STFail(description, ...) |
Generates an error. |
STAssertTrueNoThrow(expression, description, ...) |
Generates an error if expression is false or if it throws an exception. |
STAssertFalseNoThrow(expron, description, ...) |
Generates an error if expression is true or if it throws an exception |
分享到:
相关推荐
测试驱动开发(Test-Driven Development,简称TDD),是一种敏捷软件开发方法,它强调在编写实际代码之前先编写测试用例。这种方法的核心理念在于“先写测试”,即在开发任何功能之前,首先编写一个或多个测试用例来...
TDD(Test-Driven Development) 测试驱动开发是敏捷开发中的一项核心实践和技术,也是一种设计方法论。TDD得原理是在开发功能代码之前,先编写单元测试用例代码,测试代码确定需要编写什么产品代码。TDD虽是敏捷方法...
In the process, you’ll learn the basics of Django, Selenium, Git, jQuery, and Mock, along with current web development techniques. If you’re ready to take your Python skills to the next level, this ...
Test-driven development (TDD) is a modern software development practice that can dramatically reduce the number of defects in systems, produce more maintainable code, and give you the confidence to ...
Starting with the basics of TDD and reasons why its adoption is beneficial, this book will take you from the first steps of TDD with Java until you are confident enough to embrace the practice in your...
Starting with the basics of TDD and reasons why its adoption is beneficial, this book will take you from the first steps of TDD with Java until you are confident enough to embrace the practice in your...
**Ruby-TDD实战:Test Driven Development in Action** 在软件开发领域,Test-Driven Development(TDD)是一种编程实践,它强调先编写测试用例,然后编写满足这些测试的最小功能代码。Ruby作为一种动态、灵活的...
测试驱动开发(Test-Driven Development,简称TDD)是一种软件开发方法,强调在编写实际功能代码之前,先编写测试用例。这种方法的核心理念是“先写测试,再写代码”。TDD通过引入测试来引导软件设计,使得开发过程...
Test-driven development (TDD) is a development approach that relies on a test-first procedure that emphasises writing a test before writing the necessary code, and then refactoring the code to ...
测试驱动的软件开发(TDD,Test-Driven Development)是一种编程实践,强调在编写实际代码之前先编写测试用例。这种开发方式的核心理念是“先写测试,再写代码”。TDD 的工作流程通常分为三个步骤:红、绿、重构。 ...
Test Driven Development in Ruby: A Practical Introduction to TDD Using Problem and Solution Domain Analysis by Bala Paranj English | 5 Apr. 2017 | ISBN: 1484226372 | 288 Pages | PDF | 5.32 MB Learn ...
Test-Driven Development(TDD)简介,使用Nunit开发自动测试案例.
this book will take you from the first steps of TDD with Java until you are confident enough to embrace the practice in your day-to-day routine.You'll be guided through setting up tools, frameworks, ...
在软件开发领域,TDD(Test-Driven Development,测试驱动开发)是一种编程实践,它强调先编写测试用例,再编写实现功能的代码。Laravel,作为一款流行的PHP框架,高度支持TDD,使得开发者能够更高效、更稳定地构建...
测试驱动开发(TDD, Test-Driven Development)是一种软件开发方法论,它要求在编写实际功能代码之前先编写测试用例。通过这种方式,可以确保代码的质量,并且有助于降低bug出现的概率。本篇文章将详细介绍如何使用...