Can’t figure out whats going on here . . .
I’ve got a simple unit test thats designed to test a parser. Test case looks like this:
[parser didStartElement:@"mobileresponse" attributes:[NSDictionary dictionaryWithObject:@"http://www.espn.com/" forKey:@"rooturl"]];
[parser didStartElement:@"content" attributes:[NSDictionary dictionaryWithObject:@"/soccer" forKey:@"mobileFriendlyUrl"]];
NSString *mobileFriendlyURL = [parser valueForKey:@"mobile_friendly_url"];
STAssertEqualObjects(@"http://www.espn.com/soccer", mobileFriendlyURL, @"url path should be appended to root url");
now this is failing every time, but here is the output
'http://www.espn.com/soccer' should be equal to 'http://www.espn.com/soccer' url path should be appended to root url
Am I going crazy or are those the exact same?? Does anyone have any idea why this is throwing an error?
Well most probably the reason for this is that
[parser valueForKey:@"mobile_friendly_url"]doesn’t return anNSString.Consider this example (the error is there to make a point):
This will fail with the same message as yours because you have compared 2 objects that are different (even if you assumed that
mobileFriendlyURLwas anNSStringand declared its type asNSString). Finally the message just prints thedescriptionof theNSURLwhich is of course identical to your string and thus confusing you even more 🙂A quick way to test this theory is to do something like this:
Or even better do something similar to this in order to query the class:
I hope that this makes sense…