Objective-C Language Unit testing using Xcode Testing a block of code or some method:

Help us to keep this website almost Ad Free! It takes only 10 seconds of your time:
> Step 1: Go view our video on YouTube: EF Core Bulk Extensions
> Step 2: And Like the video. BONUS: You can also share it!

Example

  • Import the class, which contains the method to be tested.
  • Perform the operation with dummy data.
  • Now compare the result of operation with expected result.
- (void)testReverseString{
NSString *originalString = @"hi_my_name_is_siddharth";
NSString *reversedString = [self.someObject reverseString:originalString];
NSString *expectedReversedString = @"htrahddis_si_eman_ym_ih";
XCTAssertEqualObjects(expectedReversedString, reversedString, @"The reversed string did not match the expected reverse");
}

Feed the dummy data to the method under test if required & then compare the expected & actual results.



Got any Objective-C Language Question?