いくつかの異なるモードで実行できる一連のテストがあります。一部のグローバル構成またはフィクスチャ構成を除いて、テスト ケース コードは同じです。
ブースト テスト ライブラリで、個々のテスト ケースすべてにラッパーを記述せずにこれを実現する方法はありますか?
これはコマンド ライン スイッチではなく、同じ実行の一部である必要があります。
いくつかの異なるモードで実行できる一連のテストがあります。一部のグローバル構成またはフィクスチャ構成を除いて、テスト ケース コードは同じです。
ブースト テスト ライブラリで、個々のテスト ケースすべてにラッパーを記述せずにこれを実現する方法はありますか?
これはコマンド ライン スイッチではなく、同じ実行の一部である必要があります。
単項関数のテスト ケースは、おそらく必要なものです。唯一の欠点は、自動登録 (ある種のファクトリ関数に基づく可能性があります) がサポートされていないように見えることです。
また、テスト ケースのテンプレートがあり、自動登録されているため、構成の数が多すぎない場合は、構成ごとに型を定義することで悪用される可能性があります。
編集: テスト ケース テンプレートは、次のように使用できます。
// Parameter is the type of parameter you need. Might be anything from simple int (in
// which case the template parameter may be a value, not reference) to complex object.
// It just has to be possible to create (static) global instances of it.
template <const Parameter ¶m>
struct Fixture {
// do whatever you want, param is normal object reference here
// it's not a member, but you can:
const Parameter &getParameter() { return param; }
}
static Parameter p1(whatever);
static Parameter p2(something_else);
// ...
typedef boost::mpl::list<Fixture<p1>, Fixture<p2> > Fixtures;
BOOST_AUTO_TEST_CASE_TEMPLATE(test, F, Fixtures)
{
F fixture; // Unfortunately you can't make it true fixture, so you have to have instance
// Test what you want
}