gpt4 book ai didi

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

转载 作者:行者123 更新时间:2023-11-29 12:43:45 26 4
gpt4 key购买 nike

我正在学习 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");
}

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

最佳答案

为了让 Xcode 识别它是一个测试,您需要以“test”开始测试方法的名称。试试这个:

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

关于ios - Xcode 单元测试 - 无法添加新测试,因为它没有运行,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/24190121/

26 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com