Testadapter Einstellungen
Eine .runsettings-Datei ist als XML-Dokument aufgebaut. Das Root-Element, <RunSettings>, enthält Einstellungen, die spezifisch für Ihr Testframework sind. Das Element <QtTest> enthält Einstellungen für Qt-Unit-Tests.
Weitere Informationen über die Verwendung von .runsettings Dateien in Visual Studio finden Sie unter Konfigurieren von Unit Tests mit Hilfe einer .runsettings Datei.
Obligatorisches Element
Sie müssen die Qt-Version im Element <QtTest> festlegen.
| Name | Beschreibung | Beispiel |
|---|---|---|
| QtInstall | Gibt die Qt-Version an, die zum Erstellen und Ausführen der Tests verwendet wird. | <QtInstall>$(DefaultQtVersion)</QtInstall> |
Beispiel für minimale Laufeinstellungen
<RunSettings>
<QtTest>
<QtInstall>$(DefaultQtVersion)</QtInstall> <!-- Mandatory -->
</QtTest>
</RunSettings>Optionale Elemente
In der folgenden Tabelle sind optionale Elemente im Element <QtTest> aufgeführt.
| Name | Beschreibung | Vorkommen | Standardwert | Beispiel |
|---|---|---|---|---|
| EnabledAdapter | Aktiviert oder deaktiviert den Qt Test Adapter. | Sobald | true | <EnabledAdapter>true</EnabledAdapter> |
| ShowAdapterOutput | Zeigt die Ausgabe des Testadapters in Output > Tests an. | Einmal | false | <ShowAdapterOutput>false</ShowAdapterOutput> |
| TestTimeout | Setzt ein Timeout für einzelne Tests in Millisekunden. Ein Wert von -1 bedeutet keine Zeitüberschreitung. | Einmal | -1 | <TestTimeout>-1</TestTimeout> |
| Erkennungszeitüberschreitung | Legt eine Zeitüberschreitung für die Erkennung von Tests in Millisekunden fest. Ein Wert von -1 bedeutet keine Zeitüberschreitung. | Einmal | 2000 | <DiscoveryTimeout>2000</DiscoveryTimeout> |
| ParsePdbFiles | Analysiert PDB-Dateien, um die Quelldatei und die Zeilennummer der Testfunktionen zu ermitteln. | Einmal | true | <ParsePdbFiles>true</ParsePdbFiles> |
| UntersystemKonsoleNur | Scannt nur Konsolen-Binärdateien nach Qt Test Funktionen. | Einmal | true | <SubsystemConsoleOnly>true</SubsystemConsoleOnly> |
Abschnitt Ausgabe
Steuert den Speicherort und das Format der während der Testläufe erzeugten Protokolle.
| Name | Beschreibung | Auftreten | Beispiel |
|---|---|---|---|
| DateinameFormat | Legt fest, wie und wo die Testergebnisse geschrieben werden. Unterstützte Ausgabeformate sind: txt, csv, junitxml, xml, lightxml, teamcity und tap. | Mehrere | <FilenameFormat>PATH,OUTPUTFORMAT</FilenameFormat> |
Abschnitt Verbosität
Beeinflusst die Detailgenauigkeit der bei Testläufen erstellten Protokolle.
| Name | Beschreibung | Auftreten | Standardwert | Beispiel |
|---|---|---|---|---|
| Ebene | Der Umfang der in den Testprotokollen gemeldeten Details. | Sobald | leer | <Level>silent</Level> für minimale Ausgabe. |
| LogSignals | Protokolliert alle ausgegebenen Signale und die aus diesen Signalen resultierenden Slot-Aufrufe. | Einmal | false | <LogSignals>false</LogSignals> |
Abschnitt Commands
Beeinflussen die Art und Weise, wie Tests ausgeführt werden und steuern die Testausführungsumgebung.
| Name | Beschreibung | Auftreten | Standardwert | Beispiel |
|---|---|---|---|---|
| EreignisVerzögerung | Steuert Verzögerungen bei Ereignissimulationen. | Einmal | -1 | <EventDelay>-1</EventDelay> |
| KeyDelay | Steuerung von Verzögerungen bei Ereignissimulationen. | Einmalig | -1 | <KeyDelay>-1</KeyDelay> |
| MausVerzögerung | Steuerung von Verzögerungen bei Ereignissimulationen. | Einmalig | -1 | <MouseDelay>-1</MouseDelay> |
| MaxWarnings | Die maximale Anzahl von Warnungen, die ausgegeben werden sollen. | Einmal | 2000 | <MaxWarnings>2000</MaxWarnings> |
| NoCrashHandler | Aktiviert oder deaktiviert den Windows-Fehlerberichtsdialog. | Einmal | false | <NoCrashHandler>false</NoCrashHandler> |
Beispiel .runsettings Datei
Das folgende XML zeigt den Inhalt einer Standard Qt .runsettings Datei. Die <QtInstall> ist obligatorisch, alle anderen Elemente oder Abschnitte sind optional, da der Qt Test Adapter Standardwerte bereitstellt.
<?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>Siehe auch Tutorial: Qt Test application, Qt Tests mit einer .runsettings Datei konfigurieren, und Dateien.
© 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.