Domanda

Guardando il test dell'unità XCTEST e XCode 5 e non vedendo come eseguire i test dell'unità in Strumenti in XCode 5 ...

In particolare vorrei cercare perdite durante il test (questo non deve essere automatizzato in questa istanza, anche se chiaramente è utile).

Possibile?

È stato utile?

Soluzione

Penso che questo sia il modo più semplice:

    .
  1. Imposta un punto di interruzione da qualche parte nei test (lo sto facendo nel metodo di configurazione)
  2. Apri un nuovo documento negli strumenti
  3. Esegui l'applicazione e assicurati che sia interrotto in un punto di interruzione
  4. Dal target a discesa in strumenti scegli Allega per elaborare e scorrere verso il basso nel processo
  5. Fare clic su Record e quindi riprendere in Xcode

Altri suggerimenti

In XCode, fare clic con il tasto destro del mouse sul test nel test navigatore e selezionare "Profilo" TestName "":

 Instruments Profile Profile Unità Test Memoria

Ecco il modo giusto per farlo sotto Xcode 6:

1) Nel progetto Xcode, rivela la cartella "Prodotti", seleziona il prodotto ".xct", fare clic con il tasto destro del mouse e finalmente scegli "Rivelare in Finder" nel menu contestuale.

2) Avvia strumenti e creare un nuovo documento con il modello a scelta.

3) Fai "Scegli Target ..." per il documento

4) Naviga e seleziona lo strumento Xcode utilizza per eseguire test situati su /Applications/Xcode.app/Contents/Developer/usr/bin/xctest (è possibile trovare questa posizione utilizzando xcrun -f xctest in Terminal) - è necessario abilitare "Pacchetti trasversali" per navigare all'interno dell'app Xcode.

5) Trascina e rilascia dal Finder nel campo "Argomenti" il prodotto ".xctest" rivelato al passaggio 1 - questo entra nel suo percorso assoluto.

6) Fai clic su "Scegli".

Ora sei pronto per eseguire i test dell'unità dagli strumenti!

Inserisci Descrizione dell'immagine qui

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];
Autorizzato sotto: CC-BY-SA insieme a attribuzione
Non affiliato a StackOverflow
scroll top