Xcode 5の楽器の下でXCTESTベースのテストを実行することは可能ですか?
-
21-12-2019 - |
質問
XCDESTとXcode 5のテストを見ると、Xcode 5の機器の下で単体テストを実行する方法がわからない...
具体的には、テスト中に漏れを探したい(この例では自動化されている必要はありませんが、はっきりと便利です)。
可能?
解決
これが最も簡単な方法だと思います:
- テストのどこかにブレークポイントを設定します(セットアップ方法で実行しています)
- Instruments に新しい文書を開く
- アプリケーションを実行し、それがブレークポイント で停止していることを確認してください。
- インストゥルメントのターゲットドロップダウンから、プロセスに添付を選択してプロセスにスクロールします。
- レコードをクリックしてからxcode で再開します。
他のヒント
Xcodeで、テストナビゲータでテストを右クリックして[プロファイル "TestName" ":
を選択します。href="https://i.stack.imgur.com/8izg3.png" rel="noreferrer">
これはXcode 6の下でそれをする正しい方法:
1)Xcodeプロジェクトで、「Productess」フォルダを表示し、「.xctest」製品を選択し、右クリックして最後に「FinderでFinderで表示」を選択します。
2)楽器を起動し、選択したテンプレートを使用して新しい文書を作成します。
3)文書
の「ターゲットを選択します」 4)XcodeがXcodeを使用するXcodeを使用する/Applications/Xcode.app/Contents/Developer/usr/bin/xctest
にあるテストを実行するには(ターミナルのxcrun -f xctest
を使用してこの場所を見つけることができます) - 「トラバースパッケージ」を有効にする必要があります。
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];