I am new to ocUnit and I am trying to compare 2 arrays with the STAssertTrue and == method for equality.
The below test just queries the system under test (sut) for the returned array
- (void) testParse { SomeClassForTesting* sut = [[SomeClassForTesting alloc] init]; NSArray* result = [sut parseAndReturn]; NSArray* expected = [[NSArray alloc] initWithObjects:@"1", @"2", @"3", @"4",nil]; STAssertTrue(result == expected, @"This test failed"); }
Then inside my production code I just return the same array
- (NSArray *)parseAndReturn { NSArray* x = [[NSArray alloc] initWithObjects:@"1", @"2", @"3", @"4",nil]; return x; }
But when the test passes, I get a failure. How to compare these objects to make sure they are the same or not?
Thank you in advance
objective-c unit-testing ocunit
Toran billups
source share