Impostazioni dell'adattatore di test
Un file .runsettings è strutturato come un documento XML. L'elemento principale, <RunSettings>, contiene impostazioni specifiche per il vostro framework di test. L'elemento <QtTest> contiene le impostazioni per i test unitari Qt Test.
Per ulteriori informazioni sull'uso dei file .runsettings in Visual Studio, vedere Configurazione dei test unitari mediante un file .runsettings.
Elemento obbligatorio
È necessario impostare la versione di Qt nell'elemento <QtTest>.
| Nome | Descrizione | Esempio |
|---|---|---|
| QtInstall | Specifica la versione di Qt utilizzata per costruire ed eseguire i test. | <QtInstall>$(DefaultQtVersion)</QtInstall> |
Esempio minimo di runsettings
<RunSettings>
<QtTest>
<QtInstall>$(DefaultQtVersion)</QtInstall> <!-- Mandatory -->
</QtTest>
</RunSettings>Elementi opzionali
La tabella seguente elenca gli elementi opzionali dell'elemento <QtTest>.
| Nome | Descrizione | Ricorrenza | Valore predefinito | Esempio |
|---|---|---|---|---|
| Adattatore abilitato | Abilita o disabilita l'adattatore di Qt Test. | Una volta | true | <EnabledAdapter>true</EnabledAdapter> |
| Mostra adattatore in uscita | Mostra l'output dell'adattatore di test in Output > Tests. | Una volta | false | <ShowAdapterOutput>false</ShowAdapterOutput> |
| TestTimeout | Imposta un timeout per i singoli test in millisecondi. Un valore di -1 significa che non c'è timeout. | Una volta | -1 | <TestTimeout>-1</TestTimeout> |
| ScopertaTimeout | Imposta un timeout per la scoperta dei test in millisecondi. Un valore di -1 significa che non c'è timeout. | Una volta | 2000 | <DiscoveryTimeout>2000</DiscoveryTimeout> |
| ParsePdbFiles | Analizza i file PDB per recuperare il file sorgente e il numero di riga delle funzioni di test. | Una volta | true | <ParsePdbFiles>true</ParsePdbFiles> |
| Solo console del sottosistema | Esamina solo i file binari della console per trovare le funzioni di test di Qt Test. | Una volta | true | <SubsystemConsoleOnly>true</SubsystemConsoleOnly> |
Sezione Output
Controlla la posizione e il formato dei log generati durante l'esecuzione dei test.
| Nome | Descrizione | Occasione | Esempio |
|---|---|---|---|
| NomeFilenameFormat | Definisce come e dove vengono scritti i risultati dei test. I formati di output supportati sono: txt, csv, junitxml, xml, lightxml, teamcity e tap. | Multiplo | <FilenameFormat>PATH,OUTPUTFORMAT</FilenameFormat> |
Sezione Verbosità
Influenza la quantità di dettagli nei log generati durante l'esecuzione dei test.
| Nome | Descrizione | Occasione | Valore predefinito | Esempio |
|---|---|---|---|---|
| Livello | La quantità di dettagli riportati nei registri di test. | Una volta | vuoto | <Level>silent</Level> per un output minimo. |
| LogSegnali | Registra tutti i segnali emessi e le invocazioni di slot risultanti da tali segnali. | Una volta | false | <LogSignals>false</LogSignals> |
Sezione Comandi
Influenzano l'esecuzione dei test e controllano l'ambiente di esecuzione dei test.
| Nome | Descrizione | Occorrenza | Valore predefinito | Esempio |
|---|---|---|---|---|
| Ritardo evento | Controlla i ritardi nelle simulazioni di eventi. | Una volta | -1 | <EventDelay>-1</EventDelay> |
| Ritardo dei tasti | Controlla i ritardi nelle simulazioni di eventi. | Una volta | -1 | <KeyDelay>-1</KeyDelay> |
| Ritardo del mouse | Controlla i ritardi nelle simulazioni di eventi. | Una volta | -1 | <MouseDelay>-1</MouseDelay> |
| Avvertenze massime | Il numero massimo di avvisi da emettere. | Una volta | 2000 | <MaxWarnings>2000</MaxWarnings> |
| NoCrashHandler | Abilita o disabilita la finestra di dialogo per la segnalazione degli errori di Windows. | Una volta | false | <NoCrashHandler>false</NoCrashHandler> |
Esempio di file .runsettings
Il seguente XML mostra il contenuto di un file .runsettings predefinito di Qt. L'indirizzo <QtInstall> è obbligatorio, mentre tutti gli altri elementi o sezioni sono facoltativi perché l'adattatore Qt Test fornisce valori predefiniti.
<?xml version="1.0" encoding="utf-8"?>
<!-- File name extension must be .runsettings -->
<!-- For more information, see https://docs.microsoft.com/en-us/visualstudio/test/configure-unit-tests-by-using-a-dot-runsettings-file?view=vs-2022 -->
<RunSettings>
<QtTest>
<!-- "The Qt version used to build and run the tests. -->
<QtInstall>$(DefaultQtVersion)</QtInstall> <!-- Mandatory. -->
<!-- Enables or disables showing all output generated by the test adapter into the default
'Output | Tests' pane. The default value is false. -->
<ShowAdapterOutput>false</ShowAdapterOutput> <!-- Optional. -->
<!-- Terminates a running test if it exceeds the specified timeout in milliseconds.
A timeout of -1 means the test will not be terminated. The default value is -1. -->
<TestTimeout>-1</TestTimeout> <!-- Optional. -->
<!-- Terminates a running discovery if it exceeds the specified timeout in milliseconds.
A timeout of -1 means the test will not be terminated. The default value is 2000. -->
<DiscoveryTimeout>2000</DiscoveryTimeout> <!-- Optional. -->
<!-- Enables or disable parsing of PDB files to retrieve the source file and line number
of test functions for an executable. The default value is true. -->
<ParsePdbFiles>true</ParsePdbFiles> <!-- Optional. -->
<!-- Scan only console binaries (/SUBSYSTEM:CONSOLE) for Qt test functions. Set to false to
scan all binary types at the cost of longer discovery time. The default value is true. -->
<SubsystemConsoleOnly>true</SubsystemConsoleOnly> <!-- Optional. -->
<!-- Allows multiple FilenameFormat tags for specifying different output files and formats. -->
<Output> <!-- This section is optional. -->
<!--
Writes the test output to the specified file using the specified output format.
Supported output formats: txt, csv, junitxml, xml, lightxml, teamcity, tap. Needs
to follow this convention:
<FilenameFormat>PATH,OUTPUTFORMAT</FilenameFormat>
-->
</Output>
<!-- Control how much detail is reported in test logs. -->
<Verbosity> <!-- This section is optional. -->
<!--
Supported values: silent, v1, v2
silent: only shows fatal errors, test failures and minimal status messages.
v1: shows when each test function is entered. Only affects plain text output.
v2: Extended verbose output; shows each QCOMPARE() and QVERIFY(). This option
affects all output formats and implies -v1 for plain text output.
"The default value is empty."
-->
<Level></Level> <!-- Optional. -->
<!-- Enables or disables logging all signals that get emitted and the slot invocations
resulting from those signals. The default value is disabled. -->
<LogSignals>false</LogSignals> <!-- Optional. -->
</Verbosity>
<!-- The following command-line options influence how tests are run. -->
<Commands> <!-- This section is optional. -->
<!-- If no delay is specified for keyboard or mouse simulation
(QTest::keyClick(), QTest::mouseClick() etc.), the value from this parameter
(in milliseconds) is substituted. The default value is -1. -->
<EventDelay>-1</EventDelay> <!-- Optional. -->
<!-- Like 'EventDelay', but only influences keyboard simulation and not mouse
simulation. The default value is -1.-->
<KeyDelay>-1</KeyDelay> <!-- Optional. -->
<!-- Like 'EventDelay', but only influences mouse simulation and not keyboard
simulation. The default value is -1. -->
<MouseDelay>-1</MouseDelay> <!-- Optional. -->
<!-- Sets the maximum number of warnings to output. 0 for unlimited, defaults to 2000. -->
<MaxWarnings>2000</MaxWarnings> <!-- Optional. -->
<!-- Enables or disables the Windows Error Reporting dialog, which is disabled by
default. The default value is false. -->
<NoCrashHandler>false</NoCrashHandler> <!-- Optional. -->
</Commands>
</QtTest>
</RunSettings>Vedere anche Esercitazione: Applicazione Qt Test , Configurare i test Qt utilizzando un file .runsettings e File.
© 2026 The Qt Company Ltd. Documentation contributions included herein are the copyrights of their respective owners. The documentation provided herein is licensed under the terms of the GNU Free Documentation License version 1.3 as published by the Free Software Foundation. Qt and respective logos are trademarks of The Qt Company Ltd in Finland and/or other countries worldwide. All other trademarks are property of their respective owners.