テスト・アダプターの設定
.runsettings ファイルは XML ドキュメントとして構造化されています。ルート要素の<RunSettings> には、テストフレームワーク固有の設定があります。<QtTest> 要素には、Qt ユニットテスト用の設定があります。
Visual Studio で .runsettings ファイルを使用する方法の詳細については、.runsettings ファイルを使用してユニットテストを設定する を参照してください。
必須要素
Qt のバージョンは、<QtTest> 要素で設定する必要があります。
| 名前 | 説明 | 例 |
|---|---|---|
| QtInstall | テストのビルドと実行に使用する Qt のバージョンを指定します。 | <QtInstall>$(DefaultQtVersion)</QtInstall> |
runsettings の最小値の例
<RunSettings>
<QtTest>
<QtInstall>$(DefaultQtVersion)</QtInstall> <!-- Mandatory -->
</QtTest>
</RunSettings>オプション要素
次の表は、<QtTest> 要素のオプション要素の一覧です。
| 名前 | 説明 | 発生 | デフォルト値 | 例 |
|---|---|---|---|---|
| EnabledAdapter | Qt テストアダプタを有効または無効にします。 | 一度 | true | <EnabledAdapter>true</EnabledAdapter> |
| ShowAdapterOutput | テスト・アダプタからの出力をOutput >Tests に表示します。 | Once | false | <ShowAdapterOutput>false</ShowAdapterOutput> |
| TestTimeout | 個々のテストのタイムアウトをミリ秒単位で設定します。値 -1 は、タイムアウトがないことを意味します。 | 1 回 | -1 | <TestTimeout>-1</TestTimeout> |
| 検出タイムアウト | テスト検出のタイムアウトをミリ秒単位で設定します。値が -1 の場合、タイムアウトはありません。 | 1回 | 2000 | <DiscoveryTimeout>2000</DiscoveryTimeout> |
| ParsePdbFiles | PDBファイルを解析し、テスト関数のソースファイルと行番号を取得する。 | 1 回 | true | <ParsePdbFiles>true</ParsePdbFiles> |
| サブシステムコンソールのみ | Qt テスト関数のコンソールバイナリのみをスキャンします。 | 回 | true | <SubsystemConsoleOnly>true</SubsystemConsoleOnly> |
出力セクション
テスト実行中に生成されるログの場所と形式を制御します。
| 名前 | 説明 | 発生 | 例 |
|---|---|---|---|
| ファイル名フォーマット | テスト結果をどこにどのように書き出すかを定義します。サポートされる出力形式は、txt、csv、junitxml、xml、lightxml、teamcity、tap です。 | 複数 | <FilenameFormat>PATH,OUTPUTFORMAT</FilenameFormat> |
詳細度セクション
テスト実行中に生成されるログの詳細度に影響します。
| 名前 | 説明 | 発生 | デフォルト値 | 例 |
|---|---|---|---|---|
| レベル | テストログで報告される詳細の量。 | 一度 | 空 | <Level>silent</Level> にすると最小限の出力になります。 |
| ログシグナル | 発行されたすべてのシグナルと、そのシグナルに起因するスロットの起動をログに記録します。 | 一度だけ | false | <LogSignals>false</LogSignals> |
コマンドセクション
テストの実行方法に影響を与え、テストの実行環境を制御します。
| 名前 | 説明 | 発生 | デフォルト値 | 例 |
|---|---|---|---|---|
| イベント遅延 | イベントシミュレーションの遅延を制御する。 | 一度 | -1 | <EventDelay>-1</EventDelay> |
| キー遅延 | イベント・シミュレーションの遅延を制御します。 | 1回 | -1 | <KeyDelay>-1</KeyDelay> |
| マウス遅延 | イベントシミュレーションの遅延を制御する。 | 1回 | -1 | <MouseDelay>-1</MouseDelay> |
| 最大警告数 | 出力する警告の最大数。 | 1回 | 2000 | <MaxWarnings>2000</MaxWarnings> |
| NoCrashHandler | Windowsエラー報告ダイアログを有効または無効にする。 | 1回 | false | <NoCrashHandler>false</NoCrashHandler> |
.runsettingsファイルの例
次の XML は、デフォルトの Qt .runsettings ファイルの内容を示しています。<QtInstall> は必須です。Qt テストアダプターがデフォルト値を提供するため、他のすべての要素やセクションはオプションです。
<?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>Tutorial:Qt Test application,Configure Qt tests using a .runsettings file,Filesも参照してください 。
© 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.