Xcode单元测试 - 无法添加新测试,因为它没有运行

时间:2014-06-12 17:07:22

标签: ios xcode unit-testing methods

我正在学习Xcode中的单元测试。 Xcode为我生成了模板,但是当我添加一个新的测试方法时,它不会运行。 为什么?我已经不在乎了。我不知道为什么,我找不到任何解决方案。

    #import <XCTest/XCTest.h>

@interface TesttestTests : XCTestCase

@end

@implementation TesttestTests

 -(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)testExample
{
    XCTFail(@"No implementation for \"%s\"", __PRETTY_FUNCTION__);
}

 -(void)newtest{
    XCTAssert(false, @"This'll be false");
}

所以我添加了最后一个方法,但我的测试类无法识别它。为什么?

1 个答案:

答案 0 :(得分:1)

为了让Xcode识别它是一个测试,你需要用“test”启动测试方法的名称。试试这个:

- (void)testNew {
    XCTAssert(false, @"This'll be false");
}
相关问题