Simplified statements in OCUnit

I just started using JCUnit and I find the statements a bit cumbersome. In JUnit, I can write a test to compare numbers, as shown below. This test will obviously fail, but it shows a nice, simple statement that I can write for two numbers, and the feedback I get is: "expected <2>, but there was <3>" with very little code.

alt text

What I have tried so far I have Xcode:

alt text

Which works, but not as elegant as JUnit. Do you know if statement macros exist, like JUnit for Xcode (OCUnit)? Also, is it possible to get a red / green stripe in Xcode?

+3
source share
4

, , , OCUnit (aka SenTestingKit.framework) Xcode, Xcode. OCUnit - Objective-C, Apple .

, , , . Xcode 3.2.1, Snow Leopard. :

- (void) testNumbers {
    int number1 = 2;
    int number2 = 3;
    STAssertEquals(number1, number2, nil);
    STAssertEquals(4, 5, nil);
}

, Xcode:

-[ExampleTest testNumbers] : '2' should be equal to '3'
-[ExampleTest testNumbers] : '4' should be equal to '5'

, Xcode .

OCUnit, , , , , . 2+ 3+. (STFail 1+.) , , printf() NSLog(). nil, .

, . , , / . . .: -)

, / Xcode, JUnit. , , . YMMV.

+6

, , nil . , . , , . , , , BOOL id, NSError* :

- (void)testFoo {
  NSError *err;
  STAssertTrue([bar fooMethodReturningBOOLError:&err], @"Error: %@ (%@)", err, [err userInfo]);
}

/ , "/" , , IDE. , , , . , bugreport.apple.com. rdar://7685315 ( ).

+1

, OCHamcrest. , , - , , .

github https://github.com/hamcrest/OCHamcrest

readme

NSCalendarDate* date = [NSCalendarDate dateWithString:@"26 Apr 2008" calendarFormat:@"%d %b %Y"];
assertThat(date, is(onASaturday()))

OCUnit .

0

?

OCUnit , , . , .

-1

Source: https://habr.com/ru/post/1732415/


All Articles