我正在尝试向项目中添加测试目标,但是,当我运行测试时,似乎未在执行实际测试,而是Xcode始终报告成功,但是仍然显示一个小方块,该小方块指示测试是否通过明确。
我只有一个测试目标和一个类(class):
@implementation Tests
- (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 {
// This is an example of a functional test case.
// Use XCTAssert and related functions to verify your tests produce the correct results.
XCTAssert(false, "");
}
- (void)testPerformanceExample {
XCTAssert(false, "");
}
@end
测试应该失败,但是会显示一个弹出窗口,说明成功。另外,测试报告说没有测试。
如果我尝试单独运行测试,则测试“成功”,但是我在报告中得不到任何信息,并且方框仍然为空。
关于如何解决它的任何想法?
最佳答案
如果要针对iOS进行构建,通常是否已将Xcode设置为在物理设备上运行?如果是这样,请尝试将其设置为在iOS模拟器上运行。
我发现,如果您在物理设备上将Xcode 7设置为,则测试将完全按照您的描述进行。将Xcode设置为暂时在iOS模拟器上运行以进行单元测试可以立即解决该问题,现在它就像一个魅力一样起作用。
我希望这可以帮助遇到相同问题的任何人。 :D
关于unit-testing - Xcode 7测试未运行,但报告成功,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/32824909/