Catch2 テストの作成

Catch2 テストをビルドして実行するには、 Catch2 ライブラリとヘッダをインストールするか、 あるいは Catch2 リポジトリにある単一のインクルードヘッダファイルを使用します。

コンパイラやビルドシステムが自動的に Catch2 ヘッダを見つけられる場合は、 テストを作成する際にインクルードディレクトリを指定する必要はありません。

基本的な Catch2 テストを作成するには

  1. File >New Project >Test Project と進んでください。
  2. Catch2 Test Project >Choose を選択して、Catch2 テスト用の定型コードを含むプロジェクトを作成します。
  3. Project and Test Information ダイアログで、プロジェクトとテストの設定を指定します:

    Catch2 Test Project ウィザードの Project and Test Information ダイアログ

    1. Test framework で、Catch2 v3 (shared libraries) を選択して Catch2 とリンクするか(バージョン 3 を推奨)、Catch2 v2 (header only) を選択して単一のヘッダ・インクルードを使用します(バージョン 2 を推奨)。
    2. Test case name で、テストケースのファイル名を指定します。
    3. Catch2 install directory (optional) には、Catch2 ヘッダー・ファイルのあるディレクトリへのパスを入力します。
    4. Use own main を選択して、自分で定義したメイン関数を使用します。
    5. Use Qt libraries を選択して、Qt の機能を使用するようにプロジェクトを設定します。
    6. Build system で、プロジェクトのビルドに使用するビルド・システムを選択します:CMake、qmake、または Qbs。

Qt Creator で、プロジェクトのディレクトリにテストを作成します。

Catch2 テストを作成する方法の詳細については、Catch2 を参照してください。

注意: テストをスキャンしている間、パーサは Catch2 の共通ヘッダ (catch2.hpp,catch_all.hpp, およびその他) のいずれかを直接あるいは間接的に含むファイルのみを考慮します。現在ビルドされないファイルは無視されます。

How To: Test」「Select the build system」「Testing」「Test Results」も参照

Copyright © The Qt Company Ltd. and other contributors. 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.