Xcode 5の楽器の下でXCTESTベースのテストを実行することは可能ですか?

StackOverflow https://stackoverflow.com//questions/21031263

質問

XCDESTとXcode 5のテストを見ると、Xcode 5の機器の下で単体テストを実行する方法がわからない...

具体的には、テスト中に漏れを探したい(この例では自動化されている必要はありませんが、はっきりと便利です)。

可能?

役に立ちましたか?

解決

これが最も簡単な方法だと思います:

  1. テストのどこかにブレークポイントを設定します(セットアップ方法で実行しています)
  2. Instruments
  3. に新しい文書を開く
  4. アプリケーションを実行し、それがブレークポイント
  5. で停止していることを確認してください。
  6. インストゥルメントのターゲットドロップダウンから、プロセスに添付を選択してプロセスにスクロールします。
  7. レコードをクリックしてからxcode
  8. で再開します。

他のヒント

Xcodeで、テストナビゲータでテストを右クリックして[プロファイル "TestName" ":

を選択します。

href="https://i.stack.imgur.com/8izg3.png" rel="noreferrer"> Instruments Profile Unitテストメモリ

これは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)「選択」をクリックしてください。

あなたは今機器からあなたのユニットテストを実行する準備ができました!

Enter Image説明

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];
ライセンス: CC-BY-SA帰属
所属していません StackOverflow
scroll top