OC unit test assertions

XCTFail(format...) generates a failing test;
XCTAssertNil(a1, format...) is empty, if a1 is empty, it will pass, otherwise it will not pass;
XCTAssertNotNil(a1, format...) is not empty to judge, if a1 is not empty, it will pass, otherwise it will not pass;
XCTAssert(expression, format...) passed when expression evaluates to TRUE;
XCTAssertTrue(expression, format...) passed when expression evaluates to TRUE;
XCTAssertFalse(expression, format...) Passes when expression evaluates to False;
XCTAssertEqualObjects(a1, a2, format...) is equal to the judgment. When the value of [a1 isEqual:a2] is TRUE, it passes, and when one of them is not empty, it does not pass;
XCTAssertNotEqualObjects(a1, a2, format...) judges unequal, and passes when the value of [a1 isEqual:a2] is False;
XCTAssertEqual(a1, a2, format...) judges equality (used when a1 and a2 are C language scalars, structures or unions, the actual test found that NSString can also);
XCTAssertNotEqual(a1, a2, format...) judges unequal (used when a1 and a2 are C language scalars, structures or unions);
XCTAssertEqualWithAccuracy(a1, a2, accuracy, format...) judges equal, (double or float type) provides an error range, and passes the test when it is equal within the error range (+/-accuracy);
XCTAssertNotEqualWithAccuracy(a1, a2, accuracy, format...) Judgment is not equal, (double or float type) provides an error range, when it is not equal within the error range, it passes the test;
XCTAssertThrows(expression, format...) exception test, when the expression is abnormal, it passes; otherwise it fails; (very abnormal)
XCTAssertThrowsSpecific(expression, specificException, format...) Exception test, when specificException occurs in expression, it passes; otherwise, other exceptions or no exceptions fail;
XCTAssertThrowsSpecificNamed(expression, specificException, exception_name, format...) exception test, when the expression has a specific exception and an exception with a specific exception name, it passes the test, otherwise it fails;
XCTAssertNoThrow(expression, format...) exception test, pass the test when no exception occurs in expression;
XCTAssertNoThrowSpecific(expression, specificException, format...) exception test, when the expression does not have a specific exception or an exception with a specific exception name, it passes the test, otherwise it fails;
XCTAssertNoThrowSpecificNamed(expression, specificException, exception_name, format...) exception test, when the expression does not have a specific exception or an exception with a specific exception name, it passes the test, otherwise it fails.

 

Guess you like

Origin http://10.200.1.11:23101/article/api/json?id=326815298&siteId=291194637