目前,我在 1 个文件中编写测试(默认)。是否可以有多个文件并进行测试?
- (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.
XCTAssert(YES, @"Pass");
}
Run Code Online (Sandbox Code Playgroud)
您可以有多个文件,每个文件可以有多个测试。第一个是 Xcode 自动生成的,但它的特别之处在于:
制作另一个具有相同特征的文件很简单。
在Xcode中,File -> New -> iOS -> Source -> UI Test Case Class
约定是将相关测试分组到一个源文件中,然后将该源文件命名为 ___Tests.swift(或 .m)
例如,SharingTests.swift可能包含方法testSharingToFacebook()和testSharingToTwitter()。