Skip to content

Instantly share code, notes, and snippets.

@irshadpc
Created July 24, 2017 13:51
Show Gist options
  • Save irshadpc/c562832b0cdd234fe834cddd7d584d85 to your computer and use it in GitHub Desktop.
Save irshadpc/c562832b0cdd234fe834cddd7d584d85 to your computer and use it in GitHub Desktop.
Test basics
/*! * @class XCTestCase
* XCTestCase is a concrete subclass of XCTest that should be the override point for
* most developers creating tests for their projects. A test case subclass can have
* multiple test methods and supports setup and tear down that executes for every test
* method as well as class level setup and tear down.
*
* To define a test case:
*
* • Create a subclass of XCTestCase.
* • Implement -test methods.
* • Optionally define instance variables or properties that store the state of the test.
* • Optionally initialize state by overriding -setUp
* • Optionally clean-up after a test by overriding -tearDown.
*
* Test methods are instance methods meeting these requirements:
* • accepting no parameters
* • returning no value
* • prefixed with 'test'
*
* For example:
- (void)testSomething;
* Test methods are automatically recognized as test cases by the XCTest framework.
* Each XCTestCase subclass's defaultTestSuite is a XCTestSuite which includes these
* tests. Test method implementations usually contain assertions that must be verified
* for the test to pass, for example:
@interface MathTest : XCTestCase {
@private
float f1;
float f2;
}
- (void)testAddition;
@end
@implementation MathTest
- (void)setUp
{
f1 = 2.0;
f2 = 3.0;
}
- (void)testAddition
{
XCTAssertTrue (f1 + f2 == 5.0);
}
@end
*/
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment