Coroutine support for asynchronous tests

オープン
#3,077 コメント 2 件 リアクション 0 件 担当者 0 名 GitHub で見る

メンテナーはふだん 2 日以内に返信

@GaurRitika がすでに取り組んでいます。

2026年11月16日 から。

評価

難易度
5/5
見積もり時間
1週間以上
初心者へのやさしさ
35/100
issue の種類
機能追加
明瞭さ
おおむね明確
活発さ
停滞
技術スタック
cpp
領域
testing-qa

調査の方向性

まず Catch2 のテスト登録および実行フローを確認し、次に C++20 のコルーチンタスクをユーザー提供のスケジューリングおよびイベントループとどのように統合できるかを検討します。C++20/coroutine ビルドフラグの下でコルーチンによって定義されたテストが動作し、既存の C++14 サポートに影響がない状態をもって完了とします。

索引モデルが issue の本文から書いたものです。

説明

Description

C++20 coroutines are increasingly used for asynchronous APIs, but writing tests for coroutine-based code typically requires blocking adapters (e.g. sync_wait) or custom wrappers. This adds friction and does not work in event-loop-driven environments where blocking inside a test body is not possible.

It would therefore be useful if Catch2 supported test cases defined as coroutines, for example:

TEST_CASE_ASYNC("my async test")
{
    auto result = co_await async_operation();
    CHECK(result == 42);
}

Because Catch2 supports C++14, this feature would only be available when compiling with C++20/coroutine support. It would have to be guarded behind a build config flag.

Additional context

We have implemented a proof of concept in a private fork where we added a very basic coroutine task type. All scheduling and event-loop integration happen in user code, which keeps the approach flexible while adding minimal complexity inside Catch2. This was enough to solve related issues such as #1755 (we also target Emscripten).

I've looked at other C++ testing frameworks, but none currently seem to support coroutines natively. However, popular frameworks in other languages (e.g. C#, Python, JavaScript) support async tests, so the concept itself isn't novel.

主要言語
C++
スター
21.6k
フォーク
3.4k
平均マージ
3日 12時間
マージ済み PR(30日)
5

環境構築

はじめの一歩

  1. issue を最後まで読み、次にプロジェクトのコントリビューションガイドを読みます。
  2. 着手することを issue にコメントします — 二人が同じ作業をするのを防げます。
  3. リポジトリをフォークし、ブランチを切って変更します。
  4. issue 番号を参照したプルリクエストを送ります。

catchorg/Catch2 のほかの issue

catchorg/Catch2 の issue をすべて見る

似ている issue

C++ の issue をもっと見る

新しい issue をメールで受け取る

初心者向けの GitHub issue を短くまとめたダイジェスト。