0

내 프로젝트에 대해 UITest 사례를 작성 중입니다. 그래서 여러 파일을 XCTestCase로 하위 클래스로 만들거나 다른 테스트 클래스로 서브 클래 싱하려고합니다. 이러한 파일을 만들 때마다 다음과 같은 오류가 발생합니다.여러 XCTestCase 클래스로 UITesting

duplicate symbol _lastUsedSaveDirectory in: 
/Users/UserName/Library/Developer/Xcode/DerivedData/ProjectName/Build/Intermediates/CodeCoverage/Intermediates/Project.build/Debug/Project_UITests.build/Objects-normal/x86_64/SecondaryFile.o 
/Users/UserName/Library/Developer/Xcode/DerivedData/ProjectName/Build/Intermediates/CodeCoverage/Intermediates/Project.build/Debug/Project_UITests.build/Objects-normal/x86_64/MainFile.o 
ld: 1 duplicate symbol for architecture x86_64 
clang: error: linker command failed with exit code 1 (use -v to see invocation) 

나는 다음 그러나 아무것도 작동하지 않습니다 시도 :

1. Created "SecondaryFile" by subclassing it from "MainFile" which is a subclass of "XCTestCase". 
2. Created "SecondaryFile" by subclassing it directly from "XCTestCase". 
3. Created both .h and .m file for both the "MainFile" and "SecondaryFile" 

MainFile.m

#import <XCTest/XCTest.h> 

@interface MainFile_UITests : XCTestCase 
@end 

@implementation MainFile_UITests 

- (void)setUp { 
     [super setUp]; 

     // Put setup code here. This method is called before the invocation of each test method in the class. 

     // In UI tests it is usually best to stop immediately when a failure occurs. 
     self.continueAfterFailure = NO; 
     // UI tests must launch the application that they test. Doing this in setup will make sure it happens for each test method. 
     [[[XCUIApplication alloc] init] launch]; 
     // In UI tests it’s important to set the initial state - such as interface orientation - required for your tests before they run. The setUp method is a good place to do this. 
} 

- (void)tearDown { 
     // Put teardown code here. This method is called after the invocation of each test method in the class. 
     [super tearDown]; 
} 

- (void)testExample { 
    // Use recording to get started writing UI tests. 
     // Use XCTAssert and related functions to verify your tests produce the correct results.  
} 

@end 

SecondaryFile.m

#import <XCTest/XCTest.h> 

@interface SecondaryFile_UITests : XCTestCase 
@end 

@implementation SecondaryFile_UITests 

- (void)setUp { 
     [super setUp]; 

     // Put setup code here. This method is called before the invocation of each test method in the class. 

     // In UI tests it is usually best to stop immediately when a failure occurs. 
     self.continueAfterFailure = NO; 
     // UI tests must launch the application that they test. Doing this in setup will make sure it happens for each test method. 
     [[[XCUIApplication alloc] init] launch]; 
     // In UI tests it’s important to set the initial state - such as interface orientation - required for your tests before they run. The setUp method is a good place to do this. 
} 

- (void)tearDown { 
     // Put teardown code here. This method is called after the invocation of each test method in the class. 
     [super tearDown]; 
} 

@end 

사람은 어떻게 모듈화을 가르쳐 수/여러 파일 작성 UITesti 클래스.

+0

오류 – Oletha

+0

에서 파일 중 적어도 하나의 코드를 게시하시기 바랍니다 : 예를 들어

, 여기에 목표 - C의 서브 클래스 UITests 파일의 예입니다 파일. 의견을 부탁합니다. –

+0

프로젝트 정리 및 파생 데이터 삭제를 시도 했습니까? – Oletha

답변

0

여러 UI 테스트 파일을 사용하려면 먼저 UITests.m에 대한 헤더 파일을 만든 다음 별도의 테스트 파일에 UITest.h을 상속 받아야합니다. 그러면 하위 클래스에 UITests.msetUptearDown 개의 메소드가 제공됩니다. 그런 다음 새로운 테스트 메소드를 서브 클래스에 추가하면됩니다. 나는 모두를위한 샘플 코드를 추가 한 이 https://gist.github.com/OffensivelyBad/012043f8dab50b3b024238e985462926