How to XCode test a string

49 views Asked by At

I have to set up test cases for an assignment. I know to use STAssertEquals for numbers but I am unsure how to test the following method that returns a string.

-(NSString *) description
{
    NSLog(@"\n \n Account information for %@ \n Balance is $%g dollars \n Number of transacrions are: %d \n\n\n\n", [self owner],[self balance], [self numberOfTransactions]);

Would I use STAssertsTrue?? If so how would I apply it to the code above?

1

There are 1 answers

0
driis On

If you know the expected string result, use STAssertEqualObjects.

Since string is an NSObject, you can use STAssertEqualObjects, and it will delegate the check to the NSString implementation of object equality.