Re: Converting SenTesting framework tests to XCTests
Re: Converting SenTesting framework tests to XCTests
- Subject: Re: Converting SenTesting framework tests to XCTests
- From: Chris Hanson <email@hidden>
- Date: Thu, 10 Jul 2014 13:01:09 -0700
On Jul 10, 2014, at 12:31 PM, William Squires <email@hidden> wrote:
>
> I'm trying to convert some code that used the old(er) SenTesting framework. Now I want to use the XCTest stuff. I have the following line:
>
> STAssertEquals(<int>, <int>, NULL); // <int> is just a int-type variable or constant
>
> I figure the closest is:
>
> XCTAssertEquals, but what does the NULL in the above line do? The 3rd argument for XCTAssertEquals is (I believe) (NSString *), in which case a "nil" should work, but Xcode complains. For now, I just have:
>
> XCTAssertEquals(<int>, <int>, @"");
>
> but this seems ugly.
Actually, the correct line when using the OCUnit framework should be:
STAssertEquals(<int>, <int>, @"");
The final required parameter for OCUnit’s macros is a format string, you may have just been getting lucky passing nil or NULL instead of an empty string. (I don’t remember offhand what the OCUnit assertion macros look like.)
The XCTest framework doesn’t have this requirement; the format string for the assertions is entirely optional. That means you can just write
XCTAssertEquals(<int>, <int>);
if you don’t want to include any extra information about what the failure means or that might help you diagnose it at a glance.
Also, you should not need to perform this conversion by hand. Xcode has a conversion tool that will do this work for you, it’s available via the “Edit ▸ Refactor ▸ Convert to XCTest…” menu item.
-- Chris
_______________________________________________
Cocoa-dev mailing list (email@hidden)
Please do not post admin requests or moderator comments to the list.
Contact the moderators at cocoa-dev-admins(at)lists.apple.com
Help/Unsubscribe/Update your Subscription:
This email sent to email@hidden