IOS Unit Test

Source: Internet
Author: User
Tags scalar

Turn from: http://blog.csdn.net/jymn_chen/article/details/21552941 assertion test

The following is a total of 18 assertions (the SDK is also 18, meaning transferred from the iOS UnitTest learning notes, really admire the original blogger, some of the macro brother has been tested):

Xctfail (Format ...) generates a failed test;

Xctassertnil (A1, Format ...) For the null judgment, A1 is empty when passed, and vice versa;

Xctassertnotnil (A1, Format ...) Not for empty judgment, A1 is not empty when passed, and vice versa;

Xctassert (expression, format ...) Passed when expression evaluates to true;

Xctasserttrue (expression, format ...) Passed when expression evaluates to true;

Xctassertfalse (expression, format ...) Passed when expression evaluates to false;

Xctassertequalobjects (A1, A2, Format ...) Judgment is equal, [A1 ISEQUAL:A2] value is true when passed, one of which is not empty when not passed;

Xctassertnotequalobjects (A1, A2, Format ...) Judgment unequal, [A1 ISEQUAL:A2] value is false when passed;

Xctassertequal (A1, A2, Format ...) Judge Equality (when A1 and A2 are C scalar, struct, or union, the actual test finds that nsstring can also);

Xctassertnotequal (A1, A2, Format ...) Judgment unequal (used when A1 and A2 are C scalar, struct, or union);

Xctassertequalwithaccuracy (A1, a2, accuracy, Format ...) The judgment is equal, (double or float type) provides an error range, and passes the test when equal within the error range (+/-accuracy);

Xctassertnotequalwithaccuracy (A1, a2, accuracy, Format ...) The judgment is unequal, (double or float type) provides an error range, which passes the test when the error range is not equal;

Xctassertthrows (expression, format ...) Exception test, passed when expression has an exception; (very perverted) xctassertthrowsspecific (expression, specificexception, format ...) exception test, When expression has an specificexception exception, the other exception or no exception occurs;

xctassertthrowsspecificnamed (expression, specificexception, Exception_name, Format ...) Exception test, when expression has a specific exception, the exception of the specific exception name passed the test, and vice versa;

Xctassertnothrow (expression, format ...) An exception test, which passes the test when expression does not occur abnormally;

Xctassertnothrowspecific (expression, specificexception, format ...) Exception test, when expression does not have a specific exception, the specific exception name of the exception passed the test, and vice versa;

xctassertnothrowspecificnamed (expression, specificexception, Exception_name, Format ...) An exception test that passes the test when expression does not have an exception that has a specific exception, a specific exception name, and vice versa.

Related Article

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.