这可能非常简单/愚蠢,但我找不到它为什么会发生。
我创建了一个继承XCTestCase的自定义类。尝试运行测试时,不会执行该类中的测试。
这是我的班级:
@interface TNMediaBarTest : XCTestCase
@end
@implementation TNMediaBarTest
- (void)setUp {
[super setUp];
// Put setup code here. This method is called before the invocation of each test method in the class. }
- (void)tearDown {
// Put teardown code here. This method is called after the invocation of each test method in the class.
[super tearDown]; }
- (void)TNMediaBarLocationButtonTest {
TNMediaBar *mediaBar = [[TNMediaBar alloc] initWithFrame:CGRectZero];
XCTAssertNil(mediaBar.location, @"There's junk in location property after initialization");
[mediaBar locationButtonTapped];
XCTAssertNotNil(mediaBar.location, @"Location is empty after tapping on location button");
[mediaBar locationButtonTapped];
XCTAssertNil(mediaBar.location, @"Location is not empty after tapping on location button a second time"); }
但我明白了:
Executed 0 tests, with 0 failures (0 unexpected) in 0.000 (0.001) seconds
答案 0 :(得分:1)
您需要在测试方法的名称前加上test
,如:
- (void)testName
在您的情况下,将TNMediaBarLocationButtonTest
重命名为:
- (void)testMediaBarLocationButton