Xcode 5의 계측기에서 Xctest 기반 테스트를 실행할 수 있습니까?
-
21-12-2019 - |
문제
XCTEST 및 XCODE 5 단위 테스트를보고 Xcode 5의 계측기에서 내 장치 테스트를 실행하는 방법을 보지 못했습니다 ...
특히 테스트 중 누출을 찾고 싶습니다 (이 경우이 예에서는 자동화 할 필요는 없지만 유용 할 수 있지만 유용 할 수 있습니다).
가능?
해결책
이것은 이것이 가장 쉬운 방법이라고 생각합니다 :
- 테스트의 어딘가에 중단 점을 설정합니다 (설치 방법에서 해본 적이 있음)
- 악기에 새 문서를 엽니 다
- 응용 프로그램을 실행하고 중단 점에서 중지되었는지 확인하십시오
- 도구의 대상 드롭에서 첨부를 선택하고 프로세스로 스크롤
- 레코드를 클릭 한 다음 Xcode 재개를 클릭하십시오.
다른 팁
Xcode 6에서 수행 할 수있는 올바른 방법은 다음과 같습니다.
1) Xcode 프로젝트에서 "제품"폴더를 표시하고 ".xctest"제품을 선택하고 마우스 오른쪽 버튼을 클릭하고 마지막으로 컨텍스트 메뉴에서 "Finder에서 공개"를 선택하십시오.
2) 악기를 시작하고 원하는 템플리트로 새 문서를 만듭니다.
3) 문서의 경우 "대상 선택 ..."을 수행하십시오.
4) 공구 xcode 탐색 및 선택 /Applications/Xcode.app/Contents/Developer/usr/bin/xctest
에있는 테스트를 실행하는 데 사용합니다 (터미널에서 xcrun -f xctest
를 사용 하여이 위치를 찾을 수 있습니다). "트래버스 패키지"를 활성화하여 Xcode 응용 프로그램을 탐색해야합니다.
5) 파인더에서 "인수"필드로 끌어서 놓기 단계 1에서 밝혀진 ".xctest"제품이 절대 경로로 들어갑니다.
6) "선택"을 클릭하십시오.
이제 악기에서 장치 테스트를 실행할 준비가되었습니다!
I created a new target based on the mac app target I am testing, then added the xctest classes to the files to compile.
I then added the /Applications/Xcode.app/Contents/Developer/Platforms/MacOSX.platform/Developer/Library/Frameworks/XCTest.framework to the frameworks to link against.
Then added its path $(DEVELOPER_DIR)/Platforms/MacOSX.platform/Developer/Library/Frameworks to the Runpath Search Paths.
Then in the main.m I added the following:
XCTestSuite *suite = [XCTestSuite testSuiteWithName:@"My tests"];
[suite addTest:[VideohogCachingTest testCaseWithSelector:@selector(testCompleteSequentialText)]];
[suite run];
This ran the test testCompleteSequentialText on the class VideohogCachingTest I needed to run as a normal application, therefore allowing me to run the test by either command+R or in this case, profiling with command+I. I could then catch a zombie and trace the problem, which was not a possibility for me previously. If you'd like to run all your tests you can do:
XCTestSuite *suite = [XCTestSuite defaultTestSuite];
[suite run];