Unit Testing: Unit
testing allows programmer to refactor code at a later time and make sure that every
modules works correctly. The procedure
is to write test cases for all methods so that whenever a change causes a
fault, it can be quickly identified and solved. OCUnit is a testing framework for Objective C in iOS and Mac OS. With OCUnit testing becomes integrated with development. We can test
frameworks, bundles, or applications.These are some methods provided by OCUnit framework.
Unconditional Failure
STFail
Fails the
test case.
STFail(failure_description,
...)
|
Equality Tests
STAssertEqualObjects
Fails the
test case when two objects are different.
STAssertEqualObjects(object_1,
object_2, failure_description, ...)
|
STAssertEquals
Fails the
test case when two values are different.
STAssertEquals(value_1,
value_2, failure_description, ...)
|
STAssertEqualsWithAccuracy
Fails the
test case when the difference between two values is greater than a given value.
STAssertEqualsWithAccuracy(value_1,
value_2, accuracy, failure_description, ...)
|
Nil Tests
STAssertNil
Fails the
test case when a given expression is not nil.
STAssertNil(expression,
failure_description, ...)
|
STAssertNotNil
Fails the
test case when a given expression is nil.
STAssertNotNil(expression,
failure_description, ...)
|
Boolean Tests
STAssertTrue
Fails the
test case when a given expression is false.
STAssertTrue(expression,
failure_description, ...)
|
STAssertFalse
Fails the
test case when a given expression is true.
STAssertFalse(expression,
failure_description, ...)
|
Exception Tests
STAssertThrows
Fails the
test case when an expression doesn’t raise an exception.
STAssertThrows(expression,
failure_description, ...)
|
STAssertThrowsSpecific
Fails the
test case when an expression doesn’t raise an exception of a particular class.
STAssertThrowsSpecific(expression,
exception_class, failure_description, ...)
|
STAssertThrowsSpecificNamed
Fails the
test case when an expression doesn’t raise an exception of a particular class
with a given name.
STAssertThrowsSpecificNamed(expression,
exception_class, exception_name, failure_description, ...)
|
STAssertNoThrow
Fails the
test case when an expression raises an exception.
STAssertNoThrow(expression,
failure_description, ...)
|
STAssertNoThrowSpecific
Fails the
test case when an expression raises an exception of a particular class.
STAssertNoThrowSpecific(expression,
exception_class, failure_description, ...)
|
STAssertNoThrowSpecificNamed
Fails the
test case when an expression doesn’t raise an exception of a particular class
with a given name.
STAssertNoThrowSpecificNamed(expression,
exception_class, exception_name, failure_description, ...)
|
STAssertTrueNoThrow
Fails the
test case when an expression is false or raises an exception.
STAssertTrueNoThrow(expression,
failure_description, ...)
|
STAssertFalseNoThrow
Fails the
test case when an expression is true or raises an exception.
STAssertFalseNoThrow(expression,
failure_description, ...)
in our next post we will provide a tutorial of OCUnit Testing with Xcode.
|
Nice initiative. I hope you will update us regularly on advanced iPhone development features. :)
উত্তরমুছুনinshallah vaiya.... :)
উত্তরমুছুন