SlideShare a Scribd company logo
1 of 122
Download to read offline
Boost.Testの紹介




           @hotwatermorning

12/02/11       Boost.勉強会 #8 大阪   1
自己紹介




                  ●   @hotwatermorning
                  ●
                      札幌から来ました




12/02/11   Boost.勉強会 #8 大阪               2
自己紹介




                  ●   @hotwatermorning
                  ●
                      札幌から来ました
                  ●
                      今季は水道が2回凍結
                      しました。



12/02/11   Boost.勉強会 #8 大阪           3
自己紹介
 ●
     2011年は、
               <= C++の同人誌書いたり、




Boost.勉強会 #6 @札幌を
開催したりしました =>
                           http://www.flickr.com/photos/miio119/6318681082/

 12/02/11      Boost.勉強会 #8 大阪                                       4
Introduction




12/02/11     Boost.勉強会 #8 大阪   5
Introduction
                    今日のお話
Introduction
                ●
  What's
 Features
How to use
                ●   Boost.Testの紹介
Conclusion
                ●   Boost.TestというBoostのユニットテ
                    ストフレームワークを紹介します




               12/02/11         Boost.勉強会 #8 大阪   6
Introduction
                    主な対象者
Introduction
                ●
  What's
 Features
How to use
                ●   C++でのテストに興味がある人。
Conclusion
                ●   Boost.Testに興味がある人。
                ●   Boost.TestをDISりたい人。




               12/02/11         Boost.勉強会 #8 大阪   7
Introduction

                            〜 本日のレシピ 〜
Introduction
  What's
 Features
How to use      ●   What's the Boost.Test?
Conclusion
                    ●     Boost.Testとは?
                ●   What are the Features?
                    ●
                          どんな機能がある?
                ●   How to use the Boost.Test
                    ●     Boost.Testの使い方/書き方



               12/02/11             Boost.勉強会 #8 大阪   8
What's the Boost.Test?




12/02/11          Boost.勉強会 #8 大阪   9
What's the Boost.Test?
Introduction
  What's
                ●   Boost.Testとは
 Features
How to use
                ●   C++で書かれたC++のテストライブ
Conclusion          ラリ
                ●   Boost C++ Librariesに含まれている
                ●
                    ドキュメントが長い




               12/02/11       Boost.勉強会 #8 大阪    10
What's the Boost.Test?
Introduction
  What's
                ●   Boost.Testとは
 Features
How to use
                ●   Execution Monitor
Conclusion
                ●   Program Execution Monitor
                ●   Minimal Testing Facility
                ●   Unit Test Framework
                    の4つの機能



               12/02/11          Boost.勉強会 #8 大阪   11
What's the Boost.Test?
Introduction
  What's
                ●   Boost.Testとは
 Features
How to use
                ●   Execution Monitor
Conclusion
                ●   Program Execution Monitor
                ●   Minimal Testing Facility
                ●   Unit Test Framework
                    の4つの機能



               12/02/11          Boost.勉強会 #8 大阪   12
What's the Boost.Test?
Introduction
  What's
                ●   Execution Monitor
 Features
How to use
                ●   Boost.Testの基礎
                    関数の実行を監視して統一的な
Conclusion
                ●

                    エラーレポーティングの機能を提供
                    する。
                    ●
                      例外
                    ● UNIXのシグナル


                    ● WindowsのSEH


                ●
                    面倒なエラー検出を簡単にする。
               12/02/11         Boost.勉強会 #8 大阪   13
What's the Boost.Test?
Introduction
  What's
                ●   Execution Monitor
 Features
How to use
                ●   Boost.Testの基礎
                    関数の実行を監視して統一的な
Conclusion
                ●

                    エラーレポーティングの機能を提供
                    する。
                    ●
                      例外
                    ● UNIXのシグナル


                    ● WindowsのSEH


                ●
                    面倒なエラー検出を簡単にする。
               12/02/11         Boost.勉強会 #8 大阪   14
What's the Boost.Test?
Introduction
  What's
                ●   Execution Monitor
 Features
How to use
                ●   Boost.Testの基礎
                    受け取れる例外は3種類。
Conclusion
                ●


                    ●     C文字列
                    ●     std::string
                    ●     std::exceptionから派生したクラス



               12/02/11          Boost.勉強会 #8 大阪   15
What's the Boost.Test?
#include <stdexcept>
#include <iostream>
#include <boost/test/execution_monitor.hpp>
#include <boost/test/utils/basic_cstring/io.hpp>
int foo() {
    throw std::runtime_error("some error has occured");
    return 0;
}
int main() {
    boost::execution_monitor mon;
    try {
        return mon.execute(foo);
ᅠ ᅠ ᅠ } catch(boost::execution_exception const &e) {
ᅠ ᅠ ᅠ ᅠ std::cout << e.what() << std::endl;
ᅠ ᅠ }
}
 12/02/11                    Boost.勉強会 #8 大阪              16
What's the Boost.Test?
Introduction
  What's
                ●   Execution Monitor
 Features
How to use
                ●   Boost.Testの基礎
                    受け取れる例外は、
Conclusion
                ●

                    ●     C文字列
                    ●     std::string
                    ●     std::exceptionから派生したクラス
                          の3種類。
                    ●     これ以外の例外をExecution Monitorで捕捉
                          したい場合はexecution_monitorの
                          register_exception_translatorを使用する。
               12/02/11                 Boost.勉強会 #8 大阪         17
What's the Boost.Test?
struct my_error {
    my_error(int code) : code_(code) {}
    int      code_;
};
void trns_my_error(my_error const& e) {
    throw std::domain_error(e.code_ == 0 ? "code is zero" : "otherwise");
}
int main() {
    boost::execution_monitor mon;
    mon.register_exception_translator<my_error>(&trns_my_error);
    try {
        return mon.execute(bar); //bar may throw my_error.
      } catch(boost::execution_exception const &e) {
        std::cout << e.what() << std::endl;
    }
}

 12/02/11                    Boost.勉強会 #8 大阪                           18
What's the Boost.Test?
Introduction
  What's
                ●   Boost.Testとは
 Features
How to use
                ●   Execution Monitor
Conclusion
                ●   Program Execution Monitor
                ●   Minimal Testing Facility
                ●   Unit Test Framework
                    の4つの機能



               12/02/11          Boost.勉強会 #8 大阪   19
What's the Boost.Test?
Introduction
  What's
                ●   Program Execution Monitor
 Features
How to use
                ●   Execution Monitorで監視された環境
Conclusion          でプログラムを実行することで、
                    エラーレポーティングを簡単にす
                    る。
                ●   main関数の代わりに提供される
                    cpp_main関数からプログラムを開始
                    する。


               12/02/11         Boost.勉強会 #8 大阪   20
What's the Boost.Test?
Introduction
  What's
                ●   Program Execution Monitor
 Features
How to use
                ●   cpp_main関数内から例外がなげられ
Conclusion
                    たり、0以外の値をcpp_mainから返
                    すとエラーだとみなす。




               12/02/11         Boost.勉強会 #8 大阪   21
What's the Boost.Test?
#include <iostream>
#include <boost/test/included/prg_exec_monitor.hpp>

int cpp_main(int, char* [])
{
    std::cout << "Hello, worldn";
    return 0;
}




12/02/11             Boost.勉強会 #8 大阪              22
What's the Boost.Test?
#include <iostream>
#include <boost/test/included/prg_exec_monitor.hpp>

int cpp_main(int, char* [])
{
    std::cout << "Hello, worldn";
    return 0;
}

>./prg_exec_monitor_test.out
Hello, world

no errors detected

12/02/11             Boost.勉強会 #8 大阪              23
What's the Boost.Test?
Introduction
  What's
                ●   Boost.Testとは
 Features
How to use
                ●   Execution Monitor
Conclusion
                ●   Program Execution Monitor
                ●   Minimal Testing Facility
                ●   Unit Test Framework
                    の4つの機能



               12/02/11          Boost.勉強会 #8 大阪   24
What's the Boost.Test?
Introduction
  What's
                ●   Minimal Testing Facility
                    テスト作成のための基本的な機能を
 Features
                ●
How to use
Conclusion          提供。
                ●   Testing toolsの一部を使用できる。
                ●   boost/test/minimal.hppをインクルー
                    ドして、main関数の代わりに
                    test_main関数からプログラムを開始
                    する。


               12/02/11          Boost.勉強会 #8 大阪   25
What's the Boost.Test?
Introduction
  What's
                ●   Minimal Testing Facility
                    テスト作成のための基本的な機能を
 Features
                ●
How to use
Conclusion          提供。
                ●   Testing toolsの一部を使用できる。
                ●   boost/test/minimal.hppをインクルー
                    ドして、main関数の代わりに
                    test_main関数からプログラムを開始
                    する。


               12/02/11          Boost.勉強会 #8 大阪   26
What's the Boost.Test?
Introduction
  What's
                ●   Minimal Testing Facilityで提供されて
 Features
                    いるTesting tools
How to use
Conclusion          ●     BOOST_CHECK(pred)
                          – predがfalseならエラーレポートして継続
                    ●     BOOST_REQUIRE(pred)
                          –  predがfalseならエラーレポートして中断
                    ●     BOOST_ERROR(message)
                           – エラーレポートして継続
                    ●     BOOST_FAIL(message)
                           – エラーレポートして中断

               12/02/11             Boost.勉強会 #8 大阪    27
What's the Boost.Test?
Introduction
  What's
                ●   Minimal Testing Facility
                    ヘッダオンリーで使用できるので簡
 Features
                ●
How to use
Conclusion          単。
                    ●     一応Unit Test Framework(UTF)の方もヘッダ
                          オンリーにすることができる。
                          しかしUTFの方は長期的に使用する場合は
                          スタンドアロンライブラリとしてリンクす
                          ることが推奨される。




               12/02/11             Boost.勉強会 #8 大阪      28
What's the Boost.Test?
#include <boost/test/minimal.hpp>
int add(int i, int j) { return i*j; }

int test_main(int, char *[]) {
     BOOST_CHECK( add(2, 2) == 4 );
     BOOST_CHECK( add(2, 3) == 5 );
     return 0;
}
  >./minimal_test_test.out
  minimal_test_test.cpp(6):
  test add(2, 3) == 5 failed in function:
  'int test_main(int, char**)'

 **** 1 error detected
12/02/11             Boost.勉強会 #8 大阪        29
What's the Boost.Test?
Introduction
  What's
                ●   Boost.Testとは
 Features
How to use
                ●   Execution Monitor
Conclusion
                ●   Program Execution Monitor
                ●   Minimal Testing Facility
                ●   Unit Test Framework
                    の4つの機能



               12/02/11          Boost.勉強会 #8 大阪   30
What's the Boost.Test?
Introduction
  What's
                ●   The Unit Test Framework(UTF)
 Features
How to use
                ●   Boost.Testのメイン機能
                    ヘッダオンリーあるいはスタンドア
Conclusion
                ●

                    ロンライブラリとして使用できる。




               12/02/11         Boost.勉強会 #8 大阪    31
What's the Boost.Test?
Introduction
  What's
                ●   Unit Testing Frameworkが満たすべ
 Features
                    き要件
How to use
Conclusion      ●
                    ユニットテストの作業は、プロジェ
                    クトの実装初期からメンテナンス、
                    そして後々の改訂にいたるまで、ソ
                    フトウェア開発のさまざまな段階で
                    発生する。
                ●   そのためUnit Testing Frameworkに
                    対して(時に衝突するような)多くの
                    性質が要求される
               12/02/11       Boost.勉強会 #8 大阪   32
Requirements of UTF
●
    シンプルで、使い始めの人にも分かりやすくユニットテ
    ストモジュールが書けるべき

●
    上級者が自明でないようなテストをすることも可能であ
    るべき

●
    テストモジュールはたくさんの小さなテストケースを持
    つことができ、開発者がそれをテストスイートにグルー
    プ化することができるべき

●
    開発初期にはユーザーは詳細で説明的なエラーメッセー
    ジを見たい。しかし回帰テスト中にはどのテストが失敗
    したかだけを知りたい。
12/02/11         Boost.勉強会 #8 大阪   33
Requirements of UTF(Cont'd)
●
    小さいテストモジュールの実行時間>コンパイル時間で
    あるべき。実行に1秒しかかからないテストのコンパイ
    ルに1分も待ちたくはない。

●
    長く複雑なテストではユーザーはテストの進捗を見られ
    るようにしたい。

●
    簡単なテストは外部ライブラリを必要とするべきではな
    い。

●
    長期的な使用のためにユニットテストフレームワークは
    スタンドアロンなライブラリとしてビルドできるべき。

12/02/11           Boost.勉強会 #8 大阪       34
What's the Boost.Test?
Introduction
  What's
                ●   UTFの設計はこれらをベースにして
 Features
                    いる。そしてUTFは多岐に渡る機能
                    を提供する
How to use
Conclusion
                    ●     さまざまなTesting toolsを使用することで簡
                          単にテストを書くことができる。
                    ●
                          一つのテストツリーの中にテストケースを組
                          織化できる。
                    ●
                          面倒なエラー検出とレポーティングの義務
                          とフレームワークの実行時パラメータ処理
                          からあなたを解放する。
                          などなど。ここらへんの話は
                          http://www.boost.org/libs/test/doc/html/utf/intro.html に。
               12/02/11                     Boost.勉強会 #8 大阪                      35
What's the Boost.Test?
                    長い説明もつまらないのでちょっと
Introduction
                ●
  What's
 Features           使ってみる。
How to use
Conclusion




               12/02/11     Boost.勉強会 #8 大阪   36
What's the Boost.Test?
 
#define BOOST_TEST_MODULE SimpleTest
#include <boost/test/unit_test.hpp>


BOOST_AUTO_TEST_SUITE(simple_test_suite)
 
BOOST_AUTO_TEST_CASE(simple_test) {
    BOOST_CHECK_EQUAL(2+2, 4);
}
 
BOOST_AUTO_TEST_SUITE_END()

12/02/11             Boost.勉強会 #8 大阪       37
What's the Boost.Test?
//テストモジュールの定義
#define BOOST_TEST_MODULE SimpleTest
#include <boost/test/unit_test.hpp>

//テストスイートの定義とテストモジュールへの追加
BOOST_AUTO_TEST_SUITE(simple_test_suite)
//テストケースの定義とテストスイートへの追加
BOOST_AUTO_TEST_CASE(simple_test) {
    BOOST_CHECK_EQUAL(2+2, 4);
}

BOOST_AUTO_TEST_SUITE_END()
12/02/11             Boost.勉強会 #8 大阪       38
What's the Features?




12/02/11         Boost.勉強会 #8 大阪   39
What's the Features?
Introduction
  What's
                ●   Unit Test Frameworkの機能
 Features
How to use
                    ●     Usage Variant
Conclusion          ●
                          テストランナー
                    ●
                          モジュール初期化関数
                    ●
                          テストの作成と組織化
                    ●     Fixture
                    ●
                          テストの出力
                    ●
                          実行時のテスト設定
                    ●     Testing tools


               12/02/11           Boost.勉強会 #8 大阪   40
What's the Features?
Introduction
  What's
                ●   Unit Test Frameworkの機能
 Features
How to use
                    ●     Usage Variant
Conclusion          ●
                          テストランナー
                    ●
                          モジュール初期化関数
                    ●
                          テストの作成と組織化
                    ●     Fixture
                    ●
                          テストの出力
                    ●
                          実行時のテスト設定
                    ●     Testing tools


               12/02/11           Boost.勉強会 #8 大阪   41
What's the Features?
Introduction
  What's
                ●   Usage Variant
 Features
How to use
                ●   Testをする状況や環境に合わせて4
Conclusion
                    種類のUTFの使用法が用意されてい
                    る。




               12/02/11         Boost.勉強会 #8 大阪   42
What's the Features?
Introduction
  What's
                ●   Usage Variant
 Features
How to use
                ●   Static Library Variant
Conclusion
                ●   UTFをスタティックリンクする構成
                ●   Macでは使えない・・・?
                          http://d.hatena.ne.jp/kei10in/20100623/1277294693




               12/02/11                    Boost.勉強会 #8 大阪                    43
What's the Features?
Introduction
  What's
                ●   Usage Variant
 Features
How to use
                ●   Dynamic Library Variant
Conclusion
                ●   UTFをダイナミックリンクする構成
                ●   #define BOOST_TEST_DYN_LINK
                    ●
                          (メインになる)ただひとつのソースの
                          boost/test/unit_test.hppの、そのインクルー
                          ド前にBOOST_TEST_MAINを定義する。
                          あるいはBOOST_TEST_MODULEを使用し
                          てもOK。


               12/02/11             Boost.勉強会 #8 大阪       44
What's the Features?
Introduction
  What's
                ●   Usage Variant
 Features
How to use
                ●   Dynamic Library Variant
Conclusion
                ●   Static Library Variantを使用すると
                    バイナリが大きくなるので、Static
                    Library Variantを使用した大量のテ
                    ストのプロジェクトがあるとスト
                    レージの容量的な問題が起こるか
                    も。その場合にはDynamic Library
                    Variantを使用したほう良い。

               12/02/11         Boost.勉強会 #8 大阪    45
What's the Features?
Introduction
  What's
                ●   Usage Variant
 Features
How to use
                ●   Single-Header Variant
Conclusion
                ●   UTFをヘッダオンリーにする構成
                ●
                    テストモジュールのソースがひとつ
                    だけの時使える。
                ●
                    (コンパイル時間を考えると)長期
                    的な使用にはスタティックリンクか
                    ダイナミックリンクを使用するべき
                ●   #include <boost/test/included/unit_test.hpp>

               12/02/11              Boost.勉強会 #8 大阪               46
What's the Features?
Introduction
  What's
                ●   Usage Variant
 Features
How to use
                ●   External Test Runner Variant
                    ビルトインではないテストランナー
Conclusion
                ●

                    を使用する構成
                ●
                    テストモジュールはダイナミックリ
                    ンクライブラリとして作成する
                ●   #define BOOST_TEST_DYN_LINK



               12/02/11          Boost.勉強会 #8 大阪   47
What's the Features?
Introduction
  What's
                ●   Unit Test Frameworkの機能
 Features
How to use
                    ●     Usage Variant
Conclusion          ●
                          テストランナー
                    ●
                          モジュール初期化関数
                    ●
                          テストの作成と組織化
                    ●     Fixture
                    ●
                          テストの出力
                    ●
                          実行時のテスト設定
                    ●     Testing tools


               12/02/11           Boost.勉強会 #8 大阪   48
What's the Features?
                    テストランナー(Test Runner)
Introduction
                ●
  What's

                    テストの実行を管理する
 Features
                ●
How to use
Conclusion          ●
                          テストモジュールのエントリポイント
                    ●     実行時パラメータ(コマンドライン引数など)
                          からUTFを初期化する
                    ●     ログとテストのレポート用にOutputを準備
                    ●
                          などなど・・・




               12/02/11          Boost.勉強会 #8 大阪   49
What's the Features?
                    テストランナー(Test Runner)
Introduction
                ●
  What's

                    ビルトイン以外のテストランナーを
 Features
                ●
How to use
Conclusion          使用することができる。
                    (先進的なテストランナーはGUIや
                    テストカバレッジの機能を備えてい
                    るかも)
                    (でも見たことない)
                ●
                    今日は扱いません。あとよく分かり
                    ません。
                          語りえぬものについては、沈黙しなければ
                          ならない
               12/02/11         Boost.勉強会 #8 大阪   50
What's the Features?
Introduction
  What's
                ●   Unit Test Frameworkの機能
 Features
How to use
                    ●     Usage Variant
Conclusion          ●
                          テストランナー
                    ●
                          モジュール初期化関数
                    ●
                          テストの作成と組織化
                    ●     Fixture
                    ●
                          テストの出力
                    ●
                          実行時のテスト設定
                    ●     Testing tools


               12/02/11           Boost.勉強会 #8 大阪   51
What's the Features?
                    モジュール初期化関数
Introduction
                ●
  What's

                    テストツリーを構築するなど…?
 Features
                ●
How to use

                    ほとんどビルトインのもので済むの
Conclusion
                ●

                    で使わなくても大丈夫
                ●
                    今日は扱いません。あとよく分かり
                    ません。
                          語りえぬものについては、沈黙しなければ
                          ならない



               12/02/11         Boost.勉強会 #8 大阪   52
What's the Features?
Introduction
  What's
                ●   Unit Test Frameworkの機能
 Features
How to use
                    ●     Usage Variant
Conclusion          ●
                          テストランナー
                    ●
                          モジュール初期化関数
                    ●
                          テストの作成と組織化
                    ●     Fixture
                    ●
                          テストの出力
                    ●
                          実行時のテスト設定
                    ●     Testing tools


               12/02/11           Boost.勉強会 #8 大阪   53
What's the Features?
                    テストの定義と組織化
Introduction
                ●
  What's
 Features
How to use
Conclusion      ●
                    テストケースを作成
                ●
                    テストケースをテストスイートにグ
                    ループ化できる
                ●
                    テストスイートをさらに大きなテス
                    トスイートにグループ化できる



               12/02/11       Boost.勉強会 #8 大阪   54
What's the Boost.Test?( 再掲 )
//テストモジュールの定義
#define BOOST_TEST_MODULE SimpleTest
#include <boost/test/unit_test.hpp>

//テストスイートの定義とテストモジュールへの追加
BOOST_AUTO_TEST_SUITE(simple_test_suite)
//テストケースの定義とテストスイートへの追加
BOOST_AUTO_TEST_CASE(simple_test) {
    BOOST_CHECK_EQUAL(2+2, 4);
}

BOOST_AUTO_TEST_SUITE_END()
12/02/11             Boost.勉強会 #8 大阪       55
What's the Features?
                    テストの定義と組織化
Introduction
                ●
  What's
 Features
How to use
                ●   BOOST_AUTO_TEST_CASE(
Conclusion            test_case_name
                    )
                ●
                    引数なしテストケースを定義する
                      BOOST_AUTO_TEST_CASE(test_case_name) {
                      BOOST_AUTO_TEST_CASE(test_case_name) {
                          //test body
                          //test body
                      }
                      }
                    ●
                       手動でテストケースの登録を行う場合は、引
                       数付きのテストケースを使うことができる。

               12/02/11           Boost.勉強会 #8 大阪          56
What's the Features?
                    テストの定義と組織化
Introduction
                ●
  What's
 Features
How to use
                ●   BOOST_AUTO_TEST_CASE_TEMPLATE(
Conclusion
                      test_case_name,
                      formal_type_parameter_name,
                      collection_of_types
                    )
                ●
                    テンプレートを使用したテストケー
                    スを定義する
                ●
                    同じ内容で型のみが異なるテストを
                    書くときに便利

               12/02/11        Boost.勉強会 #8 大阪       57
What's the Features?
                    テストの定義と組織化
Introduction
                ●
  What's
 Features
How to use
                ●   BOOST_AUTO_TEST_SUITE(
Conclusion            test_suite_name
                    )
                ●
                    テストスイートを定義する
                    BOOST_AUTO_TEST_SUITE(test_suite_name)
                    BOOST_AUTO_TEST_SUITE(test_suite_name)
                    // some tests
                    // some tests
                    // BOOST_AUTO_TEST_CASE(test1)
                    // BOOST_AUTO_TEST_CASE(test1)
                    // { /**/ }
                    // { /**/ }
                    BOOST_AUTO_TEST_SUITE_END()
                    BOOST_AUTO_TEST_SUITE_END()
               12/02/11           Boost.勉強会 #8 大阪            58
What's the Features?
                    テストの定義と組織化
Introduction
                ●
  What's

                    テストケースはテストスイートのなか
 Features
                ●

                    に複数含めることができる。
How to use
Conclusion

                ●
                    テストスイートは入れ子になること
                    ができる。




               12/02/11       Boost.勉強会 #8 大阪   59
What's the Boost.Test?
#include <boost/test/unit_test.hpp>
BOOST_AUTO_TEST_SUITE(suite1)

      BOOST_AUTO_TEST_SUITE(suite2)

           BOOST_AUTO_TEST_CASE(test1) { /**/ }
           BOOST_AUTO_TEST_CASE(test2) { /**/ }

      BOOST_AUTO_TEST_SUITE_END()

      BOOST_AUTO_TEST_CASE(test3) { /**/ }

BOOST_AUTO_TEST_SUITE_END()
12/02/11                Boost.勉強会 #8 大阪           60
What's the Boost.Test?

                   Master Test Suite
                   Master Test Suite

                        suite1
                        suite1


                                             suite2
                                             suite2


           test3
           test3                         test2
                                         test2        test1
                                                      test1


12/02/11               Boost.勉強会 #8 大阪                    61
What's the Features?
Introduction
  What's
                ●   Unit Test Frameworkの機能
 Features
How to use
                    ●     Usage Variant
Conclusion          ●
                          テストランナー
                    ●
                          モジュール初期化関数
                    ●
                          テストの作成と組織化
                    ●     Fixture
                    ●
                          テストの出力
                    ●
                          実行時のテスト設定
                    ●     Testing tools


               12/02/11           Boost.勉強会 #8 大阪   62
What's the Features?
Introduction
  What's
                ●   Fixture
                    テストケースなどで以下の役割を担
 Features
                ●
How to use
Conclusion          う
                    ●
                          テスト開始前に状態を整える
                    ●
                          テストに関する特定の状態を用意する
                    ●
                          テスト終了後にクリーンアップをする




               12/02/11         Boost.勉強会 #8 大阪   63
What's the Features?
Introduction
  What's
                ●   Generic Fixture Model
 Features
How to use
Conclusion
                 struct <fixture-name>{
                 struct <fixture-name>{
                    <fixture-name>(); // setup function
                    <fixture-name>(); // setup function
                    ~<fixture-name>(); // teardown function
                    ~<fixture-name>(); // teardown function
                 };
                 };




               12/02/11          Boost.勉強会 #8 大阪          64
What's the Boost.Test?
//Fixtureを使ったテストの例
struct MyFixture {
     MyFixture() { i = new int; *i = 0 }
      ~ MyFixture() { delete i; }
    int * i;
};
BOOST_AUTO_TEST_CASE( test_case1 )
{
    MyFixture f;
    // do something involving f.i
}


12/02/11             Boost.勉強会 #8 大阪       65
What's the Boost.Test?
//Fixtureを使ったテストの例
struct MyFixture {
     MyFixture() { i = new int; *i = 0 }
      ~ MyFixture() { delete i; }
    int * i;
};
BOOST_AUTO_TEST_CASE( test_case1 )
{
    MyFixture f;
    // do something involving f.i
}


12/02/11             Boost.勉強会 #8 大阪       66
What's the Boost.Test?
struct MyFixture {
     MyFixture() { i = new int; *i = 0 }
      ~ MyFixture() { delete i; }
    int * i;
};
BOOST_FIXTURE_TEST_CASE( test_case1, MyFixture )
{
    // do something involving i
}
// test_cast1を開始する前にMyFixtureを構築して、
// test_case1が終わるとMyFixtureを破棄する



12/02/11             Boost.勉強会 #8 大阪               67
What's the Features?
Introduction
  What's
                ●   Fixture
                    テストケースなどで以下の役割を担
 Features
                ●
How to use
Conclusion          う
                    ●
                          テスト開始前に状態を整える
                    ●
                          テストに関する特定の状態を用意する
                    ●
                          テスト終了後にクリーンアップをする




               12/02/11         Boost.勉強会 #8 大阪   68
What's the Features?
Introduction
  What's
                ●   Fixture
 Features
How to use
                ●   3つのレベルでSetupとCleanupを行
Conclusion          うことができる
                    ●
                          テストケース
                    ●
                          テストスイート
                    ●
                          グローバル




               12/02/11         Boost.勉強会 #8 大阪   69
What's the Features?
Introduction
  What's
                ●   Fixtureの設定
 Features
How to use
                ●   BOOST_FIXTURE_TEST_CASE(
Conclusion
                      test_case_name,
                      fixure_name)
                ●   テストケースごとのFixtureを設定




               12/02/11       Boost.勉強会 #8 大阪   70
What's the Features?
Introduction
  What's
                ●   Fixtureの設定
 Features
How to use
                ●   BOOST_FIXTURE_TEST_SUITE(
Conclusion
                      test_suite_name,
                      fixure_name)
                ●   テストスイートごとのFixtureを設定
                ●
                    テストスイート内の各テストケース
                    が同じFixtureを使用したいときの為
                    にテストスイートレベルでFixtureを
                    使用できる。
               12/02/11       Boost.勉強会 #8 大阪   71
What's the Features?
Introduction
  What's
                ●   Fixtureの設定
 Features
How to use
                ●   BOOST_GLOBAL_FIXTURE(
Conclusion
                      fixure_name)
                ●   グローバルなFixtureを設定
                ●
                    テストの開始時の初期化を担う
                ●
                    テスト用の各ソースファイルに複数
                    の別のグローバルなFixtureを設定す
                    ることも可能

               12/02/11       Boost.勉強会 #8 大阪   72
What's the Features?
Introduction
  What's
                ●   Fixtureの設定
 Features
How to use
                ●   BOOST_GLOBAL_FIXTURE(
Conclusion
                      fixure_name)
                ●   グローバルなFixtureを設定
                ●
                    テストの開始時の初期化を担う
                ●
                    テスト用の各ソースファイルに複数
                    の別のグローバルなFixtureを設定す
                    ることも可能
                ●
                    でもデストラクト順が厄介・・・?
               12/02/11       Boost.勉強会 #8 大阪   73
What's the Boost.Test?
struct F1 {
    F1() {
         std::cout << "F1" << std::endl;
    }
      ~F1() {
         std::cout << "~F1" << std::endl;
    }
};
//同様にF2, F3を定義する




12/02/11             Boost.勉強会 #8 大阪        74
What's the Boost.Test?
BOOST_GLOBAL_FIXTURE(F1);
BOOST_GLOBAL_FIXTURE(F2);
BOOST_GLOBAL_FIXTURE(F3);

BOOST_AUTO_TEST_SUITE(global_fixture_test_suite)

BOOST_AUTO_TEST_CASE(global_fixture_test)
{
    //nop
}

BOOST_AUTO_TEST_SUITE_END()

12/02/11             Boost.勉強会 #8 大阪               75
What's the Boost.Test?
BOOST_GLOBAL_FIXTURE(F1);
BOOST_GLOBAL_FIXTURE(F2);
BOOST_GLOBAL_FIXTURE(F3);

BOOST_AUTO_TEST_SUITE(global_fixture_test_suite)

BOOST_AUTO_TEST_CASE(global_fixture_test)
{                             F1
    //nop                     F2
}                             F3
                              Running 1 test case...
                              ~F1
BOOST_AUTO_TEST_SUITE_END() ~F2
                              ~F3
12/02/11             Boost.勉強会 #8 大阪               76
What's the Features?
Introduction
  What's
                ●   Unit Test Frameworkの機能
 Features
How to use
                    ●     Usage Variant
Conclusion          ●
                          テストランナー
                    ●
                          モジュール初期化関数
                    ●
                          テストの作成と組織化
                    ●     Fixture
                    ●
                          テストの出力
                    ●
                          実行時のテスト設定
                    ●     Testing tools


               12/02/11           Boost.勉強会 #8 大阪   77
What's the Features?
                    テストの出力
Introduction
                ●
  What's

                    全てのテストで統一的なレポートを
 Features
                ●
How to use
Conclusion      ●
                    エラーについて、ソース上の詳細な
                    情報を
                ●   テストのエラーの記述(test log)はテ
                    スト結果の要約(test results report)
                    とは分離する
                ●
                    柔軟な出力内容
                ●
                    柔軟な出力の形式
               12/02/11       Boost.勉強会 #8 大阪      78
What's the Features?
                    テストの出力
Introduction
                ●
  What's
 Features
How to use
                ●   Test Log
Conclusion
                ●   Test Report
                ●   Progress Display




               12/02/11           Boost.勉強会 #8 大阪   79
What's the Features?
                    テストの出力
Introduction
                ●
  What's
 Features
How to use
                ●   Test Log
Conclusion
                ●   Test Report
                ●   Progress Display




               12/02/11           Boost.勉強会 #8 大阪   80
What's the Features?
                    テストの出力
Introduction
                ●
  What's
 Features
How to use
                ●   Test Logのレベル
Conclusion          ●     Success information messages
                    ●     Test tree traversal notifications
                    ●     General information messages
                    ●     Warning messages
                    ●     Non fatal error messages
                    ●     Uncaught C++ exceptions notifications
                    ●     Non-fatal system error
                    ●     Fatal system error
               12/02/11                  Boost.勉強会 #8 大阪          81
What's the Features?
                    テストの出力
Introduction
                ●
  What's
 Features
How to use
                ●   Test Logのレベル
                    各レベルは下のレベルの内容を含む
Conclusion
                ●


                ●   デフォルトはNon fatal error messages
                ●
                    各レベルの詳細は
                    http://www.boost.org/libs/test/doc/html/utf/user-guide/test-output/test-log.htm

                    を参照。


               12/02/11                        Boost.勉強会 #8 大阪                                82
What's the Features?
                    テストの出力
Introduction
                ●
  What's
 Features
How to use
                ●   operator<<のインターフェースを持
Conclusion          たない型がlogに出力されようとした
                    ときはコンパイルエラーになる。
                ●
                    そのコンパイルエラーを避ける場
                    合、あるいはlogに出力したくない場
                    合は
                    BOOST_TEST_DONT_PRINT_LOG_VALUE(
                     ArgumentType )
                    を使用する
               12/02/11        Boost.勉強会 #8 大阪         83
What's the Features?
                    テストの出力
Introduction
                ●
  What's
 Features
How to use          BOOST_TEST_MESSAGE(
Conclusion            test_message )
                ●   Logにメッセージをさしこむ
                ●   ただし、デフォルトのLogレベルの
                    設定では出力されない
                ●   LogレベルをGeneral information messages
                    以上にする

               12/02/11         Boost.勉強会 #8 大阪       84
What's the Features?
                    テストの出力
Introduction
                ●
  What's
 Features
How to use
                ●   Test Logのレベル
                    各レベルの詳細は
Conclusion
                ●

                    http://www.boost.org/libs/test/doc/html/utf/user-guide/test-output/test-log.html


                    を参照。




               12/02/11                            Boost.勉強会 #8 大阪                                     85
What's the Features?
                    テストの出力
Introduction
                ●
  What's
 Features
How to use          BOOST_TEST_CHECKPOINT(
Conclusion            checkpoint_message)
                ●   Logに名前付きのチェックポイント
                    をさしこむ




               12/02/11       Boost.勉強会 #8 大阪   86
What's the Features?
                    テストの出力
Introduction
                ●
  What's
 Features
How to use
                ●   Logの出力フォーマット
Conclusion
                    ●     Human Readable
                          – Microsoft系C++コンパイラのエ
                            ラー記述に似た形式でLogを出
                            力
                    ●     XML
                          – XML形式でLogを出力


               12/02/11          Boost.勉強会 #8 大阪   87
What's the Features?
                    テストの出力
Introduction
                ●
  What's
 Features
How to use
                ●   Logの出力先をコンパイル時に設定
Conclusion
                    unit_test_log.set_stream(
                      std::ostream& str );




               12/02/11          Boost.勉強会 #8 大阪   88
What's the Boost.Test?
struct MyConfig {
    MyConfig() : test_log( "example.log" )     {
            boost::unit_test::unit_test_log.set_stream( test_log );
    }
      ~MyConfig()                                  {
            boost::unit_test::unit_test_log.set_stream( std::cout );
    }
    std::ofstream test_log;
};
BOOST_GLOBAL_FIXTURE( MyConfig );
BOOST_AUTO_TEST_CASE( test_case )
{
    //...



 12/02/11                        Boost.勉強会 #8 大阪                       89
What's the Features?
                    テストの出力
Introduction
                ●
  What's
 Features
How to use
                ●   Log出力のレベルをコンパイル時に
Conclusion          設定する
                    unit_test_log.set_threshold_level(
                      boost::unit_test::log_level );




               12/02/11         Boost.勉強会 #8 大阪          90
What's the Features?
using namespace boost::unit_test;
BOOST_AUTO_TEST_CASE( test_case0 )
{
    if ( runtime_config::log_level() <
         log_warnings )
        unit_test_log.set_threshold_level(
            log_warnings );
    BOOST_WARN( sizeof(int) > 4 );
}




12/02/11             Boost.勉強会 #8 大阪         91
What's the Features?
                    テストの出力
Introduction
                ●
  What's
 Features
How to use
                ●   Test Log
Conclusion
                ●   Test Report
                ●   Progress Display




               12/02/11           Boost.勉強会 #8 大阪   92
What's the Features?
                    テストの出力
Introduction
                ●
  What's

                    テストレポートの出力
 Features
                ●
How to use
Conclusion          ●     Runtime configuration
                    ●     Compile time configuration
                    ●     Report output stream redirection and access
                    ●     Report level configuration
                    ●     Predefined report format selection
                    ●     Custom report format support



               12/02/11                 Boost.勉強会 #8 大阪             93
What's the Features?
                    テストの出力
Introduction
                ●
  What's

                    テストレポートの出力
 Features
                ●
How to use
Conclusion          ●     Runtime configuration
                    ●     Compile time configuration
                    ●     Report output stream redirection and access
                    ●     Report level configuration
                    ●     Predefined report format selection
                    ●     Custom report format support
                ●
                    ドキュメントに詳細がない・・・?

               12/02/11                 Boost.勉強会 #8 大阪             94
What's the Features?
                    テストの出力
Introduction
                ●
  What's
 Features
How to use
                ●   Test Log
Conclusion
                ●   Test Report
                ●   Progress Display




               12/02/11           Boost.勉強会 #8 大阪   95
What's the Features?
                    テストの出力
Introduction
                ●
  What's
 Features
How to use
                ●   Progress Display
                    次に紹介する実行時設定
Conclusion
                ●

                    show_progress
                    を使用する。
                    > example --show_progress=yes --log_level=nothing

                    0%   10   20   30   40   50   60   70   80   90   100%
                    |----|----|----|----|----|----|----|----|----|----|
                    ***************************************************

                    *** No errors detected



               12/02/11                  Boost.勉強会 #8 大阪                     96
What's the Features?
Introduction
  What's
                ●   Unit Test Frameworkの機能
 Features
How to use
                    ●     Usage Variant
Conclusion          ●
                          テストランナー
                    ●
                          モジュール初期化関数
                    ●
                          テストの作成と組織化
                    ●     Fixture
                    ●
                          テストの出力
                    ●
                          実行時のテスト設定
                    ●     Testing tools


               12/02/11           Boost.勉強会 #8 大阪   97
What's the Features?
                    実行時のテスト設定
Introduction
                ●
  What's

                    環境変数、あるいは実行時引数でロ
 Features
                ●

                    グ出力の挙動を設定する
How to use
Conclusion

                    ●     auto_start_dbg
                    ●     build_info
                    ●     catch_system_errors
                    ●     detect_memory_leak
                    ●     detect_fp_exceptions



               12/02/11                Boost.勉強会 #8 大阪   98
What's the Features?
                    実行時のテスト設定
Introduction
                ●
  What's

                    環境変数、あるいは実行時引数でロ
 Features
                ●

                    グ出力の挙動を設定する
How to use
Conclusion

                    ●     log_format
                    ●     log_level
                    ●     output_format
                    ●     random
                    ●     report_format



               12/02/11                   Boost.勉強会 #8 大阪   99
What's the Features?
                    実行時のテスト設定
Introduction
                ●
  What's

                    環境変数、あるいは実行時引数でロ
 Features
                ●

                    グ出力の挙動を設定する
How to use
Conclusion

                    ●     report_level
                    ●     result_code
                    ●     run_test
                    ●     show_progress
                    ●     use_alt_stack



               12/02/11                   Boost.勉強会 #8 大阪   100
What's the Features?
Introduction
  What's
                ●   Unit Test Frameworkの機能
 Features
How to use
                    ●     Usage Variant
Conclusion          ●
                          テストランナー
                    ●
                          モジュール初期化関数
                    ●
                          テストの作成と組織化
                    ●     Fixture
                    ●
                          テストの出力
                    ●
                          実行時のテスト設定
                    ●     Testing tools


               12/02/11           Boost.勉強会 #8 大阪   101
What's the Features?
                    Testing tools
Introduction
                ●
  What's

                    Minimal Testing Facilityの例で使
 Features
                ●

                    用したBOOST_CHECKなど
How to use
Conclusion




               12/02/11       Boost.勉強会 #8 大阪      102
What's the Features?
                    Testing tools
Introduction
                ●
  What's

                    複数のマクロと関数宣言からなる
 Features
                ●

                    ツール集。
How to use
Conclusion

                ●
                    テストの作成と管理を容易にして、
                    統一的なエラーレポーティングの仕
                    組みを提供する。
                ●
                    全てのツールは自動的にエラーレ
                    ポーティングにエラーの位置情報
                    (ファイル名と行番号)

               12/02/11       Boost.勉強会 #8 大阪   103
What's the Features?
                    Testing tools flavors
Introduction
                ●
  What's

                    全てのテストツールにはflavorsが提
 Features
                ●

                    供されている
How to use
Conclusion

                ●
                    テストツールのアサーションについ
                    てのレベル的なもの




               12/02/11       Boost.勉強会 #8 大阪   104
What's the Features?
                    Testing tools flavors
Introduction
                ●
  What's

                    WARN
 Features
                ●
How to use
Conclusion          ●
                      警告
                    ●
                      エラーカウント:そのまま
                    ●
                      テストの実行:継続




               12/02/11       Boost.勉強会 #8 大阪   105
What's the Features?
                    Testing tools flavors
Introduction
                ●
  What's

                    CHECK
 Features
                ●
How to use
Conclusion          ●
                      エラーチェック
                    ●
                      エラーカウント:増加
                    ●
                      テストの実行:継続




               12/02/11        Boost.勉強会 #8 大阪   106
What's the Features?
                    Testing tools flavors
Introduction
                ●
  What's

                    REQUIRE
 Features
                ●
How to use
Conclusion          ●
                      必要条件チェック
                    ●
                      エラーカウント:増加
                    ●
                      テストの実行:中断




               12/02/11        Boost.勉強会 #8 大阪   107
What's the Features?
                    提供されているTesting tools
Introduction
                ●
  What's

                    BOOST_<level>
 Features
                ●
How to use
Conclusion
                          BOOST_CHECK( i == 1 );
                          BOOST_CHECK( i == 1 );
                          BOOST_REQUIRE( !str.empty() );
                          BOOST_REQUIRE( !str.empty() );


               Running 1 test case...
               testing_tool_test.cpp:10: error in "testing_tool_test":
                check i == 1 failed
               testing_tool_test.cpp:11: fatal error in "testing_tool_test":
                critical check !str.empty() failed

               *** 2 failures detected in test suite "Master Test Suite"



               12/02/11                Boost.勉強会 #8 大阪                     108
What's the Features?
                    提供されているTesting tools
Introduction
                ●
  What's

                    BOOST_<level>_EQUAL
 Features
                ●
How to use
Conclusion
                      BOOST_CHECK_EQUAL( i, 1 );
                      BOOST_CHECK_EQUAL( i, 1 );
                      BOOST_REQUIRE_EQUAL( str, “STRING” );
                      BOOST_REQUIRE_EQUAL( str, “STRING” );


                Running 1 test case...
                testing_tool_test.cpp:10: error in "testing_tool_test":
                 check i == 1 failed [0 != 1]
                testing_tool_test.cpp:11: fatal error in "testing_tool_test":
                 critical check str == "STRING" failed [ != STRING]

                *** 2 failures detected in test suite "Master Test Suite"



               12/02/11                Boost.勉強会 #8 大阪                      109
What's the Features?
                    提供されているTesting tools
Introduction
                ●
  What's

                    などなど・・・
 Features
                ●
How to use
Conclusion      ●
                    詳しくはドキュメントに書いてあり
                    ます。




               12/02/11       Boost.勉強会 #8 大阪   110
What's the Features?
                    提供されているTesting tools
Introduction
                ●
  What's

                    Testing toolsを使うことでテストの
 Features
                ●

                    意味を分かりやすく書くことがで
How to use
Conclusion

                    き、さらに統一的なエラーレポー
                    ティングができるようになる。




               12/02/11       Boost.勉強会 #8 大阪   111
How to use the Boost.Test




12/02/11            Boost.勉強会 #8 大阪    112
How to use the Boost.Test
                    デモ
Introduction
                ●
  What's
 Features
How to use
Conclusion




               12/02/11    Boost.勉強会 #8 大阪   113
Conclusion




12/02/11    Boost.勉強会 #8 大阪   114
Conclusion
Introduction
  What's
                ●   Boost.Testを使うことで、C++のテ
 Features
                    ストを自動的に組織しながらテスト
How to use
Conclusion
                    を書くことができる。
                ●
                    実行時引数を設定することで、柔軟
                    にテストをすることができる。
                ●   Testing toolsを使うことでテスト内
                    容を明確にすることができる。
                ●   (Boostに含まれてるので)普段から
                    Boostを使っている人は導入しやす
                    い。
               12/02/11        Boost.勉強会 #8 大阪   115
Conclusion
                    欠点
Introduction
                ●
  What's

                    実行時にスキップするテストを選ぶ
 Features
                ●

                    ことが出来ない
How to use
Conclusion

                ●   Mockの仕組みがない
                ●
                    テスト出力のストリームがワイド文
                    字列対応していない




               12/02/11        Boost.勉強会 #8 大阪   116
Conclusion
                    欠点
Introduction
                ●
  What's

                    実行時にスキップするテストを選ぶ
 Features
                ●

                    ことが出来ない
How to use
Conclusion

                ●   Mockの仕組みがない
                ●
                    テスト出力のストリームがワイド文
                    字列対応していない




               12/02/11        Boost.勉強会 #8 大阪   117
Conclusion
Introduction
  What's
                ●   Mockの仕組みがない
 Features
                    http://alexott.net/en/cpp/CppTestingIntro.html
How to use
Conclusion      ●   ここにGoogle MockとBoost.Testを
                    組み合わせたテストの紹介がありま
                    す。




               12/02/11                     Boost.勉強会 #8 大阪          118
Conclusion
Introduction
  What's
                ●   Mockの仕組みがない
                    アンドキュメントだがあるらし
 Features
                ●
How to use
Conclusion          い・・・?(@cpp_akiraさん情報ありがとうございます)
                    ●     see boost/libs/test/example/example/est_example1.cpp
                    ●     see boost/libs/test/example/example/est_example2.cpp




               12/02/11                      Boost.勉強会 #8 大阪                     119
Conclusion
                    参考文献/サイト
Introduction
                ●
  What's
 Features           ●     http://www.boost.org/libs/test/doc/html/
How to use          ●     http://alexott.net/en/cpp/CppTestingIntro.html
Conclusion          ●     http://www.alittlemadness.com/2009/03/31/c-unit-testing-with-boosttest/
                    ●     http://blog.livedoor.jp/naoya_t/archives/51043392.html




               12/02/11                             Boost.勉強会 #8 大阪                                 120
Conclusion
                    質問など・・・
Introduction
                ●
  What's
 Features
How to use
Conclusion




               12/02/11        Boost.勉強会 #8 大阪   121
Thank You!
           ありがとうございました!



12/02/11      Boost.勉強会 #8 大阪   122

More Related Content

What's hot

不遇の標準ライブラリ - valarray
不遇の標準ライブラリ - valarray不遇の標準ライブラリ - valarray
不遇の標準ライブラリ - valarrayRyosuke839
 
【Unite Tokyo 2018】さては非同期だなオメー!async/await完全に理解しよう
【Unite Tokyo 2018】さては非同期だなオメー!async/await完全に理解しよう【Unite Tokyo 2018】さては非同期だなオメー!async/await完全に理解しよう
【Unite Tokyo 2018】さては非同期だなオメー!async/await完全に理解しようUnity Technologies Japan K.K.
 
TVMの次期グラフIR Relayの紹介
TVMの次期グラフIR Relayの紹介TVMの次期グラフIR Relayの紹介
TVMの次期グラフIR Relayの紹介Takeo Imai
 
Apache Arrow - データ処理ツールの次世代プラットフォーム
Apache Arrow - データ処理ツールの次世代プラットフォームApache Arrow - データ処理ツールの次世代プラットフォーム
Apache Arrow - データ処理ツールの次世代プラットフォームKouhei Sutou
 
ARM CPUにおけるSIMDを用いた高速計算入門
ARM CPUにおけるSIMDを用いた高速計算入門ARM CPUにおけるSIMDを用いた高速計算入門
ARM CPUにおけるSIMDを用いた高速計算入門Fixstars Corporation
 
CUDAのアセンブリ言語基礎のまとめ PTXとSASSの概説
CUDAのアセンブリ言語基礎のまとめ PTXとSASSの概説CUDAのアセンブリ言語基礎のまとめ PTXとSASSの概説
CUDAのアセンブリ言語基礎のまとめ PTXとSASSの概説Takateru Yamagishi
 
CPU / GPU高速化セミナー!性能モデルの理論と実践:実践編
CPU / GPU高速化セミナー!性能モデルの理論と実践:実践編CPU / GPU高速化セミナー!性能モデルの理論と実践:実践編
CPU / GPU高速化セミナー!性能モデルの理論と実践:実践編Fixstars Corporation
 
Effective Modern C++ 勉強会 Item 22
Effective Modern C++ 勉強会 Item 22Effective Modern C++ 勉強会 Item 22
Effective Modern C++ 勉強会 Item 22Keisuke Fukuda
 
SAT/SMTソルバの仕組み
SAT/SMTソルバの仕組みSAT/SMTソルバの仕組み
SAT/SMTソルバの仕組みMasahiro Sakai
 
Pythonの理解を試みる 〜バイトコードインタプリタを作成する〜
Pythonの理解を試みる 〜バイトコードインタプリタを作成する〜Pythonの理解を試みる 〜バイトコードインタプリタを作成する〜
Pythonの理解を試みる 〜バイトコードインタプリタを作成する〜Preferred Networks
 
20分くらいでわかった気分になれるC++20コルーチン
20分くらいでわかった気分になれるC++20コルーチン20分くらいでわかった気分になれるC++20コルーチン
20分くらいでわかった気分になれるC++20コルーチンyohhoy
 
CUDAプログラミング入門
CUDAプログラミング入門CUDAプログラミング入門
CUDAプログラミング入門NVIDIA Japan
 
非制約最小二乗密度比推定法 uLSIF を用いた外れ値検出
非制約最小二乗密度比推定法 uLSIF を用いた外れ値検出非制約最小二乗密度比推定法 uLSIF を用いた外れ値検出
非制約最小二乗密度比推定法 uLSIF を用いた外れ値検出hoxo_m
 
GPUが100倍速いという神話をぶち殺せたらいいな ver.2013
GPUが100倍速いという神話をぶち殺せたらいいな ver.2013GPUが100倍速いという神話をぶち殺せたらいいな ver.2013
GPUが100倍速いという神話をぶち殺せたらいいな ver.2013Ryo Sakamoto
 
RSA暗号運用でやってはいけない n のこと #ssmjp
RSA暗号運用でやってはいけない n のこと #ssmjpRSA暗号運用でやってはいけない n のこと #ssmjp
RSA暗号運用でやってはいけない n のこと #ssmjpsonickun
 
【解説】 一般逆行列
【解説】 一般逆行列【解説】 一般逆行列
【解説】 一般逆行列Kenjiro Sugimoto
 
中3女子でもわかる constexpr
中3女子でもわかる constexpr中3女子でもわかる constexpr
中3女子でもわかる constexprGenya Murakami
 

What's hot (20)

不遇の標準ライブラリ - valarray
不遇の標準ライブラリ - valarray不遇の標準ライブラリ - valarray
不遇の標準ライブラリ - valarray
 
LLVM最適化のこつ
LLVM最適化のこつLLVM最適化のこつ
LLVM最適化のこつ
 
【Unite Tokyo 2018】さては非同期だなオメー!async/await完全に理解しよう
【Unite Tokyo 2018】さては非同期だなオメー!async/await完全に理解しよう【Unite Tokyo 2018】さては非同期だなオメー!async/await完全に理解しよう
【Unite Tokyo 2018】さては非同期だなオメー!async/await完全に理解しよう
 
TVMの次期グラフIR Relayの紹介
TVMの次期グラフIR Relayの紹介TVMの次期グラフIR Relayの紹介
TVMの次期グラフIR Relayの紹介
 
Apache Arrow - データ処理ツールの次世代プラットフォーム
Apache Arrow - データ処理ツールの次世代プラットフォームApache Arrow - データ処理ツールの次世代プラットフォーム
Apache Arrow - データ処理ツールの次世代プラットフォーム
 
ARM CPUにおけるSIMDを用いた高速計算入門
ARM CPUにおけるSIMDを用いた高速計算入門ARM CPUにおけるSIMDを用いた高速計算入門
ARM CPUにおけるSIMDを用いた高速計算入門
 
CUDAのアセンブリ言語基礎のまとめ PTXとSASSの概説
CUDAのアセンブリ言語基礎のまとめ PTXとSASSの概説CUDAのアセンブリ言語基礎のまとめ PTXとSASSの概説
CUDAのアセンブリ言語基礎のまとめ PTXとSASSの概説
 
CPU / GPU高速化セミナー!性能モデルの理論と実践:実践編
CPU / GPU高速化セミナー!性能モデルの理論と実践:実践編CPU / GPU高速化セミナー!性能モデルの理論と実践:実践編
CPU / GPU高速化セミナー!性能モデルの理論と実践:実践編
 
Rの高速化
Rの高速化Rの高速化
Rの高速化
 
Effective Modern C++ 勉強会 Item 22
Effective Modern C++ 勉強会 Item 22Effective Modern C++ 勉強会 Item 22
Effective Modern C++ 勉強会 Item 22
 
SAT/SMTソルバの仕組み
SAT/SMTソルバの仕組みSAT/SMTソルバの仕組み
SAT/SMTソルバの仕組み
 
Pythonの理解を試みる 〜バイトコードインタプリタを作成する〜
Pythonの理解を試みる 〜バイトコードインタプリタを作成する〜Pythonの理解を試みる 〜バイトコードインタプリタを作成する〜
Pythonの理解を試みる 〜バイトコードインタプリタを作成する〜
 
20分くらいでわかった気分になれるC++20コルーチン
20分くらいでわかった気分になれるC++20コルーチン20分くらいでわかった気分になれるC++20コルーチン
20分くらいでわかった気分になれるC++20コルーチン
 
CUDAプログラミング入門
CUDAプログラミング入門CUDAプログラミング入門
CUDAプログラミング入門
 
非制約最小二乗密度比推定法 uLSIF を用いた外れ値検出
非制約最小二乗密度比推定法 uLSIF を用いた外れ値検出非制約最小二乗密度比推定法 uLSIF を用いた外れ値検出
非制約最小二乗密度比推定法 uLSIF を用いた外れ値検出
 
深層強化学習と実装例
深層強化学習と実装例深層強化学習と実装例
深層強化学習と実装例
 
GPUが100倍速いという神話をぶち殺せたらいいな ver.2013
GPUが100倍速いという神話をぶち殺せたらいいな ver.2013GPUが100倍速いという神話をぶち殺せたらいいな ver.2013
GPUが100倍速いという神話をぶち殺せたらいいな ver.2013
 
RSA暗号運用でやってはいけない n のこと #ssmjp
RSA暗号運用でやってはいけない n のこと #ssmjpRSA暗号運用でやってはいけない n のこと #ssmjp
RSA暗号運用でやってはいけない n のこと #ssmjp
 
【解説】 一般逆行列
【解説】 一般逆行列【解説】 一般逆行列
【解説】 一般逆行列
 
中3女子でもわかる constexpr
中3女子でもわかる constexpr中3女子でもわかる constexpr
中3女子でもわかる constexpr
 

Viewers also liked

C++コミュニティーの中心でC++をDISる
C++コミュニティーの中心でC++をDISるC++コミュニティーの中心でC++をDISる
C++コミュニティーの中心でC++をDISるHideyuki Tanaka
 
Boost.Timer
Boost.TimerBoost.Timer
Boost.Timermelpon
 
Pub/Sub model, msm, and asio
Pub/Sub model, msm, and asioPub/Sub model, msm, and asio
Pub/Sub model, msm, and asioTakatoshi Kondo
 
C++14 solve explicit_default_constructor
C++14 solve explicit_default_constructorC++14 solve explicit_default_constructor
C++14 solve explicit_default_constructorAkira Takahashi
 

Viewers also liked (7)

Boost sg msgpack
Boost sg msgpackBoost sg msgpack
Boost sg msgpack
 
C++コミュニティーの中心でC++をDISる
C++コミュニティーの中心でC++をDISるC++コミュニティーの中心でC++をDISる
C++コミュニティーの中心でC++をDISる
 
C++14 enum hash
C++14 enum hashC++14 enum hash
C++14 enum hash
 
Boost.Timer
Boost.TimerBoost.Timer
Boost.Timer
 
Pub/Sub model, msm, and asio
Pub/Sub model, msm, and asioPub/Sub model, msm, and asio
Pub/Sub model, msm, and asio
 
Glfw3,OpenGL,GUI
Glfw3,OpenGL,GUI Glfw3,OpenGL,GUI
Glfw3,OpenGL,GUI
 
C++14 solve explicit_default_constructor
C++14 solve explicit_default_constructorC++14 solve explicit_default_constructor
C++14 solve explicit_default_constructor
 

Similar to Introduction to boost test

第4回勉強会 単体テストのすすめ
第4回勉強会 単体テストのすすめ第4回勉強会 単体テストのすすめ
第4回勉強会 単体テストのすすめhakoika-itwg
 
はこだてIKA 第4回勉強会 単体テスト
はこだてIKA 第4回勉強会 単体テストはこだてIKA 第4回勉強会 単体テスト
はこだてIKA 第4回勉強会 単体テストSeiji KOMATSU
 
Unit testで定時帰宅!
Unit testで定時帰宅!Unit testで定時帰宅!
Unit testで定時帰宅!Funato Takashi
 
Gui自動テストツール基本
Gui自動テストツール基本Gui自動テストツール基本
Gui自動テストツール基本Tsuyoshi Yumoto
 
ぼくのかんがえた iOSテスト戦略
ぼくのかんがえた iOSテスト戦略ぼくのかんがえた iOSテスト戦略
ぼくのかんがえた iOSテスト戦略Naoki Umehara
 
How to introduce test automation in VeriServe Test Automation Talk #2
How to introduce test automation in VeriServe Test Automation Talk #2How to introduce test automation in VeriServe Test Automation Talk #2
How to introduce test automation in VeriServe Test Automation Talk #2Sadaaki Emura
 
Go1.8 for Google App Engine
Go1.8 for Google App EngineGo1.8 for Google App Engine
Go1.8 for Google App EngineTakuya Ueda
 
Tokyor14 - R言語でユニットテスト
Tokyor14 - R言語でユニットテストTokyor14 - R言語でユニットテスト
Tokyor14 - R言語でユニットテストYohei Sato
 
ソフトウェア・テスト入門5
ソフトウェア・テスト入門5ソフトウェア・テスト入門5
ソフトウェア・テスト入門5Kenta Hattori
 
PF開発に使えるAOSPのツール達
PF開発に使えるAOSPのツール達PF開発に使えるAOSPのツール達
PF開発に使えるAOSPのツール達l_b__
 
わんくま名古屋 #32 (20140823) TDD道場 #20
わんくま名古屋 #32 (20140823) TDD道場 #20わんくま名古屋 #32 (20140823) TDD道場 #20
わんくま名古屋 #32 (20140823) TDD道場 #20Yasuhiko Yamamoto
 
nGrinder3 : だれもが簡単にできる性能テスト
nGrinder3 : だれもが簡単にできる性能テストnGrinder3 : だれもが簡単にできる性能テスト
nGrinder3 : だれもが簡単にできる性能テストJunHo Yoon
 
Getting Started with Testing using PHPUnit
Getting Started with Testing using PHPUnitGetting Started with Testing using PHPUnit
Getting Started with Testing using PHPUnitAtsuhiro Kubo
 
ゼロから始めたE2Eテスト
ゼロから始めたE2Eテストゼロから始めたE2Eテスト
ゼロから始めたE2Eテストushiboy
 
Androidリリース作業の効率化(2)
Androidリリース作業の効率化(2)Androidリリース作業の効率化(2)
Androidリリース作業の効率化(2)Kenichi Kambara
 
ワンクリックデプロイ101 #ocdeploy
ワンクリックデプロイ101 #ocdeployワンクリックデプロイ101 #ocdeploy
ワンクリックデプロイ101 #ocdeployRyutaro YOSHIBA
 

Similar to Introduction to boost test (20)

第4回勉強会 単体テストのすすめ
第4回勉強会 単体テストのすすめ第4回勉強会 単体テストのすすめ
第4回勉強会 単体テストのすすめ
 
はこだてIKA 第4回勉強会 単体テスト
はこだてIKA 第4回勉強会 単体テストはこだてIKA 第4回勉強会 単体テスト
はこだてIKA 第4回勉強会 単体テスト
 
Unit testで定時帰宅!
Unit testで定時帰宅!Unit testで定時帰宅!
Unit testで定時帰宅!
 
Gui自動テストツール基本
Gui自動テストツール基本Gui自動テストツール基本
Gui自動テストツール基本
 
ぼくのかんがえた iOSテスト戦略
ぼくのかんがえた iOSテスト戦略ぼくのかんがえた iOSテスト戦略
ぼくのかんがえた iOSテスト戦略
 
XP祭り2013-LT-Codeer
XP祭り2013-LT-CodeerXP祭り2013-LT-Codeer
XP祭り2013-LT-Codeer
 
How to introduce test automation in VeriServe Test Automation Talk #2
How to introduce test automation in VeriServe Test Automation Talk #2How to introduce test automation in VeriServe Test Automation Talk #2
How to introduce test automation in VeriServe Test Automation Talk #2
 
Go1.8 for Google App Engine
Go1.8 for Google App EngineGo1.8 for Google App Engine
Go1.8 for Google App Engine
 
開発ワークフロー
開発ワークフロー開発ワークフロー
開発ワークフロー
 
Tokyor14 - R言語でユニットテスト
Tokyor14 - R言語でユニットテストTokyor14 - R言語でユニットテスト
Tokyor14 - R言語でユニットテスト
 
ソフトウェア・テスト入門5
ソフトウェア・テスト入門5ソフトウェア・テスト入門5
ソフトウェア・テスト入門5
 
PF開発に使えるAOSPのツール達
PF開発に使えるAOSPのツール達PF開発に使えるAOSPのツール達
PF開発に使えるAOSPのツール達
 
わんくま名古屋 #32 (20140823) TDD道場 #20
わんくま名古屋 #32 (20140823) TDD道場 #20わんくま名古屋 #32 (20140823) TDD道場 #20
わんくま名古屋 #32 (20140823) TDD道場 #20
 
nGrinder3 : だれもが簡単にできる性能テスト
nGrinder3 : だれもが簡単にできる性能テストnGrinder3 : だれもが簡単にできる性能テスト
nGrinder3 : だれもが簡単にできる性能テスト
 
Gamedevenvstudy1
Gamedevenvstudy1Gamedevenvstudy1
Gamedevenvstudy1
 
Getting Started with Testing using PHPUnit
Getting Started with Testing using PHPUnitGetting Started with Testing using PHPUnit
Getting Started with Testing using PHPUnit
 
ゼロから始めたE2Eテスト
ゼロから始めたE2Eテストゼロから始めたE2Eテスト
ゼロから始めたE2Eテスト
 
Androidリリース作業の効率化(2)
Androidリリース作業の効率化(2)Androidリリース作業の効率化(2)
Androidリリース作業の効率化(2)
 
ワンクリックデプロイ101 #ocdeploy
ワンクリックデプロイ101 #ocdeployワンクリックデプロイ101 #ocdeploy
ワンクリックデプロイ101 #ocdeploy
 
CMSI計算科学技術特論C (2015) OpenMX とDFT②
CMSI計算科学技術特論C (2015) OpenMX とDFT②CMSI計算科学技術特論C (2015) OpenMX とDFT②
CMSI計算科学技術特論C (2015) OpenMX とDFT②
 

More from Kohsuke Yuasa

オーディオ用レベルメータを作ってみよう
オーディオ用レベルメータを作ってみようオーディオ用レベルメータを作ってみよう
オーディオ用レベルメータを作ってみようKohsuke Yuasa
 
Juceで作るオーディオアプリケーション
Juceで作るオーディオアプリケーションJuceで作るオーディオアプリケーション
Juceで作るオーディオアプリケーションKohsuke Yuasa
 
C++ マルチスレッドプログラミング
C++ マルチスレッドプログラミングC++ マルチスレッドプログラミング
C++ マルチスレッドプログラミングKohsuke Yuasa
 
イマドキC++erのモテカワリソース管理術
イマドキC++erのモテカワリソース管理術イマドキC++erのモテカワリソース管理術
イマドキC++erのモテカワリソース管理術Kohsuke Yuasa
 
最近のC++ @ Sapporo.cpp #5
最近のC++ @ Sapporo.cpp #5最近のC++ @ Sapporo.cpp #5
最近のC++ @ Sapporo.cpp #5Kohsuke Yuasa
 
規格書で読むC++11のスレッド
規格書で読むC++11のスレッド規格書で読むC++11のスレッド
規格書で読むC++11のスレッドKohsuke Yuasa
 
C++ ポインタ ブートキャンプ
C++ ポインタ ブートキャンプC++ ポインタ ブートキャンプ
C++ ポインタ ブートキャンプKohsuke Yuasa
 
Sapporocpp#2 exception-primer
Sapporocpp#2 exception-primerSapporocpp#2 exception-primer
Sapporocpp#2 exception-primerKohsuke Yuasa
 

More from Kohsuke Yuasa (11)

オーディオ用レベルメータを作ってみよう
オーディオ用レベルメータを作ってみようオーディオ用レベルメータを作ってみよう
オーディオ用レベルメータを作ってみよう
 
Juceで作るオーディオアプリケーション
Juceで作るオーディオアプリケーションJuceで作るオーディオアプリケーション
Juceで作るオーディオアプリケーション
 
C++ マルチスレッドプログラミング
C++ マルチスレッドプログラミングC++ マルチスレッドプログラミング
C++ マルチスレッドプログラミング
 
イマドキC++erのモテカワリソース管理術
イマドキC++erのモテカワリソース管理術イマドキC++erのモテカワリソース管理術
イマドキC++erのモテカワリソース管理術
 
最近のC++ @ Sapporo.cpp #5
最近のC++ @ Sapporo.cpp #5最近のC++ @ Sapporo.cpp #5
最近のC++ @ Sapporo.cpp #5
 
規格書で読むC++11のスレッド
規格書で読むC++11のスレッド規格書で読むC++11のスレッド
規格書で読むC++11のスレッド
 
C++ ポインタ ブートキャンプ
C++ ポインタ ブートキャンプC++ ポインタ ブートキャンプ
C++ ポインタ ブートキャンプ
 
C++ template-primer
C++ template-primerC++ template-primer
C++ template-primer
 
Read egg oven
Read egg ovenRead egg oven
Read egg oven
 
Study3 boost
Study3 boostStudy3 boost
Study3 boost
 
Sapporocpp#2 exception-primer
Sapporocpp#2 exception-primerSapporocpp#2 exception-primer
Sapporocpp#2 exception-primer
 

Recently uploaded

【早稲田AI研究会 講義資料】3DスキャンとTextTo3Dのツールを知ろう!(Vol.1)
【早稲田AI研究会 講義資料】3DスキャンとTextTo3Dのツールを知ろう!(Vol.1)【早稲田AI研究会 講義資料】3DスキャンとTextTo3Dのツールを知ろう!(Vol.1)
【早稲田AI研究会 講義資料】3DスキャンとTextTo3Dのツールを知ろう!(Vol.1)Hiroki Ichikura
 
自分史上一番早い2024振り返り〜コロナ後、仕事は通常ペースに戻ったか〜 by IoT fullstack engineer
自分史上一番早い2024振り返り〜コロナ後、仕事は通常ペースに戻ったか〜 by IoT fullstack engineer自分史上一番早い2024振り返り〜コロナ後、仕事は通常ペースに戻ったか〜 by IoT fullstack engineer
自分史上一番早い2024振り返り〜コロナ後、仕事は通常ペースに戻ったか〜 by IoT fullstack engineerYuki Kikuchi
 
クラウドネイティブなサーバー仮想化基盤 - OpenShift Virtualization.pdf
クラウドネイティブなサーバー仮想化基盤 - OpenShift Virtualization.pdfクラウドネイティブなサーバー仮想化基盤 - OpenShift Virtualization.pdf
クラウドネイティブなサーバー仮想化基盤 - OpenShift Virtualization.pdfFumieNakayama
 
SOPを理解する 2024/04/19 の勉強会で発表されたものです
SOPを理解する       2024/04/19 の勉強会で発表されたものですSOPを理解する       2024/04/19 の勉強会で発表されたものです
SOPを理解する 2024/04/19 の勉強会で発表されたものですiPride Co., Ltd.
 
TataPixel: 畳の異方性を利用した切り替え可能なディスプレイの提案
TataPixel: 畳の異方性を利用した切り替え可能なディスプレイの提案TataPixel: 畳の異方性を利用した切り替え可能なディスプレイの提案
TataPixel: 畳の異方性を利用した切り替え可能なディスプレイの提案sugiuralab
 
モーダル間の変換後の一致性とジャンル表を用いた解釈可能性の考察 ~Text-to-MusicとText-To-ImageかつImage-to-Music...
モーダル間の変換後の一致性とジャンル表を用いた解釈可能性の考察  ~Text-to-MusicとText-To-ImageかつImage-to-Music...モーダル間の変換後の一致性とジャンル表を用いた解釈可能性の考察  ~Text-to-MusicとText-To-ImageかつImage-to-Music...
モーダル間の変換後の一致性とジャンル表を用いた解釈可能性の考察 ~Text-to-MusicとText-To-ImageかつImage-to-Music...博三 太田
 
CTO, VPoE, テックリードなどリーダーポジションに登用したくなるのはどんな人材か?
CTO, VPoE, テックリードなどリーダーポジションに登用したくなるのはどんな人材か?CTO, VPoE, テックリードなどリーダーポジションに登用したくなるのはどんな人材か?
CTO, VPoE, テックリードなどリーダーポジションに登用したくなるのはどんな人材か?akihisamiyanaga1
 
デジタル・フォレンジックの最新動向(2024年4月27日情洛会総会特別講演スライド)
デジタル・フォレンジックの最新動向(2024年4月27日情洛会総会特別講演スライド)デジタル・フォレンジックの最新動向(2024年4月27日情洛会総会特別講演スライド)
デジタル・フォレンジックの最新動向(2024年4月27日情洛会総会特別講演スライド)UEHARA, Tetsutaro
 
AWS の OpenShift サービス (ROSA) を使った OpenShift Virtualizationの始め方.pdf
AWS の OpenShift サービス (ROSA) を使った OpenShift Virtualizationの始め方.pdfAWS の OpenShift サービス (ROSA) を使った OpenShift Virtualizationの始め方.pdf
AWS の OpenShift サービス (ROSA) を使った OpenShift Virtualizationの始め方.pdfFumieNakayama
 

Recently uploaded (9)

【早稲田AI研究会 講義資料】3DスキャンとTextTo3Dのツールを知ろう!(Vol.1)
【早稲田AI研究会 講義資料】3DスキャンとTextTo3Dのツールを知ろう!(Vol.1)【早稲田AI研究会 講義資料】3DスキャンとTextTo3Dのツールを知ろう!(Vol.1)
【早稲田AI研究会 講義資料】3DスキャンとTextTo3Dのツールを知ろう!(Vol.1)
 
自分史上一番早い2024振り返り〜コロナ後、仕事は通常ペースに戻ったか〜 by IoT fullstack engineer
自分史上一番早い2024振り返り〜コロナ後、仕事は通常ペースに戻ったか〜 by IoT fullstack engineer自分史上一番早い2024振り返り〜コロナ後、仕事は通常ペースに戻ったか〜 by IoT fullstack engineer
自分史上一番早い2024振り返り〜コロナ後、仕事は通常ペースに戻ったか〜 by IoT fullstack engineer
 
クラウドネイティブなサーバー仮想化基盤 - OpenShift Virtualization.pdf
クラウドネイティブなサーバー仮想化基盤 - OpenShift Virtualization.pdfクラウドネイティブなサーバー仮想化基盤 - OpenShift Virtualization.pdf
クラウドネイティブなサーバー仮想化基盤 - OpenShift Virtualization.pdf
 
SOPを理解する 2024/04/19 の勉強会で発表されたものです
SOPを理解する       2024/04/19 の勉強会で発表されたものですSOPを理解する       2024/04/19 の勉強会で発表されたものです
SOPを理解する 2024/04/19 の勉強会で発表されたものです
 
TataPixel: 畳の異方性を利用した切り替え可能なディスプレイの提案
TataPixel: 畳の異方性を利用した切り替え可能なディスプレイの提案TataPixel: 畳の異方性を利用した切り替え可能なディスプレイの提案
TataPixel: 畳の異方性を利用した切り替え可能なディスプレイの提案
 
モーダル間の変換後の一致性とジャンル表を用いた解釈可能性の考察 ~Text-to-MusicとText-To-ImageかつImage-to-Music...
モーダル間の変換後の一致性とジャンル表を用いた解釈可能性の考察  ~Text-to-MusicとText-To-ImageかつImage-to-Music...モーダル間の変換後の一致性とジャンル表を用いた解釈可能性の考察  ~Text-to-MusicとText-To-ImageかつImage-to-Music...
モーダル間の変換後の一致性とジャンル表を用いた解釈可能性の考察 ~Text-to-MusicとText-To-ImageかつImage-to-Music...
 
CTO, VPoE, テックリードなどリーダーポジションに登用したくなるのはどんな人材か?
CTO, VPoE, テックリードなどリーダーポジションに登用したくなるのはどんな人材か?CTO, VPoE, テックリードなどリーダーポジションに登用したくなるのはどんな人材か?
CTO, VPoE, テックリードなどリーダーポジションに登用したくなるのはどんな人材か?
 
デジタル・フォレンジックの最新動向(2024年4月27日情洛会総会特別講演スライド)
デジタル・フォレンジックの最新動向(2024年4月27日情洛会総会特別講演スライド)デジタル・フォレンジックの最新動向(2024年4月27日情洛会総会特別講演スライド)
デジタル・フォレンジックの最新動向(2024年4月27日情洛会総会特別講演スライド)
 
AWS の OpenShift サービス (ROSA) を使った OpenShift Virtualizationの始め方.pdf
AWS の OpenShift サービス (ROSA) を使った OpenShift Virtualizationの始め方.pdfAWS の OpenShift サービス (ROSA) を使った OpenShift Virtualizationの始め方.pdf
AWS の OpenShift サービス (ROSA) を使った OpenShift Virtualizationの始め方.pdf
 

Introduction to boost test

  • 1. Boost.Testの紹介 @hotwatermorning 12/02/11 Boost.勉強会 #8 大阪 1
  • 2. 自己紹介 ● @hotwatermorning ● 札幌から来ました 12/02/11 Boost.勉強会 #8 大阪 2
  • 3. 自己紹介 ● @hotwatermorning ● 札幌から来ました ● 今季は水道が2回凍結 しました。 12/02/11 Boost.勉強会 #8 大阪 3
  • 4. 自己紹介 ● 2011年は、 <= C++の同人誌書いたり、 Boost.勉強会 #6 @札幌を 開催したりしました => http://www.flickr.com/photos/miio119/6318681082/ 12/02/11 Boost.勉強会 #8 大阪 4
  • 5. Introduction 12/02/11 Boost.勉強会 #8 大阪 5
  • 6. Introduction 今日のお話 Introduction ● What's Features How to use ● Boost.Testの紹介 Conclusion ● Boost.TestというBoostのユニットテ ストフレームワークを紹介します 12/02/11 Boost.勉強会 #8 大阪 6
  • 7. Introduction 主な対象者 Introduction ● What's Features How to use ● C++でのテストに興味がある人。 Conclusion ● Boost.Testに興味がある人。 ● Boost.TestをDISりたい人。 12/02/11 Boost.勉強会 #8 大阪 7
  • 8. Introduction 〜 本日のレシピ 〜 Introduction What's Features How to use ● What's the Boost.Test? Conclusion ● Boost.Testとは? ● What are the Features? ● どんな機能がある? ● How to use the Boost.Test ● Boost.Testの使い方/書き方 12/02/11 Boost.勉強会 #8 大阪 8
  • 9. What's the Boost.Test? 12/02/11 Boost.勉強会 #8 大阪 9
  • 10. What's the Boost.Test? Introduction What's ● Boost.Testとは Features How to use ● C++で書かれたC++のテストライブ Conclusion ラリ ● Boost C++ Librariesに含まれている ● ドキュメントが長い 12/02/11 Boost.勉強会 #8 大阪 10
  • 11. What's the Boost.Test? Introduction What's ● Boost.Testとは Features How to use ● Execution Monitor Conclusion ● Program Execution Monitor ● Minimal Testing Facility ● Unit Test Framework の4つの機能 12/02/11 Boost.勉強会 #8 大阪 11
  • 12. What's the Boost.Test? Introduction What's ● Boost.Testとは Features How to use ● Execution Monitor Conclusion ● Program Execution Monitor ● Minimal Testing Facility ● Unit Test Framework の4つの機能 12/02/11 Boost.勉強会 #8 大阪 12
  • 13. What's the Boost.Test? Introduction What's ● Execution Monitor Features How to use ● Boost.Testの基礎 関数の実行を監視して統一的な Conclusion ● エラーレポーティングの機能を提供 する。 ● 例外 ● UNIXのシグナル ● WindowsのSEH ● 面倒なエラー検出を簡単にする。 12/02/11 Boost.勉強会 #8 大阪 13
  • 14. What's the Boost.Test? Introduction What's ● Execution Monitor Features How to use ● Boost.Testの基礎 関数の実行を監視して統一的な Conclusion ● エラーレポーティングの機能を提供 する。 ● 例外 ● UNIXのシグナル ● WindowsのSEH ● 面倒なエラー検出を簡単にする。 12/02/11 Boost.勉強会 #8 大阪 14
  • 15. What's the Boost.Test? Introduction What's ● Execution Monitor Features How to use ● Boost.Testの基礎 受け取れる例外は3種類。 Conclusion ● ● C文字列 ● std::string ● std::exceptionから派生したクラス 12/02/11 Boost.勉強会 #8 大阪 15
  • 16. What's the Boost.Test? #include <stdexcept> #include <iostream> #include <boost/test/execution_monitor.hpp> #include <boost/test/utils/basic_cstring/io.hpp> int foo() { throw std::runtime_error("some error has occured"); return 0; } int main() { boost::execution_monitor mon; try { return mon.execute(foo); ᅠ ᅠ ᅠ } catch(boost::execution_exception const &e) { ᅠ ᅠ ᅠ ᅠ std::cout << e.what() << std::endl; ᅠ ᅠ } } 12/02/11 Boost.勉強会 #8 大阪 16
  • 17. What's the Boost.Test? Introduction What's ● Execution Monitor Features How to use ● Boost.Testの基礎 受け取れる例外は、 Conclusion ● ● C文字列 ● std::string ● std::exceptionから派生したクラス の3種類。 ● これ以外の例外をExecution Monitorで捕捉 したい場合はexecution_monitorの register_exception_translatorを使用する。 12/02/11 Boost.勉強会 #8 大阪 17
  • 18. What's the Boost.Test? struct my_error { my_error(int code) : code_(code) {} int code_; }; void trns_my_error(my_error const& e) { throw std::domain_error(e.code_ == 0 ? "code is zero" : "otherwise"); } int main() { boost::execution_monitor mon; mon.register_exception_translator<my_error>(&trns_my_error); try { return mon.execute(bar); //bar may throw my_error. } catch(boost::execution_exception const &e) { std::cout << e.what() << std::endl; } } 12/02/11 Boost.勉強会 #8 大阪 18
  • 19. What's the Boost.Test? Introduction What's ● Boost.Testとは Features How to use ● Execution Monitor Conclusion ● Program Execution Monitor ● Minimal Testing Facility ● Unit Test Framework の4つの機能 12/02/11 Boost.勉強会 #8 大阪 19
  • 20. What's the Boost.Test? Introduction What's ● Program Execution Monitor Features How to use ● Execution Monitorで監視された環境 Conclusion でプログラムを実行することで、 エラーレポーティングを簡単にす る。 ● main関数の代わりに提供される cpp_main関数からプログラムを開始 する。 12/02/11 Boost.勉強会 #8 大阪 20
  • 21. What's the Boost.Test? Introduction What's ● Program Execution Monitor Features How to use ● cpp_main関数内から例外がなげられ Conclusion たり、0以外の値をcpp_mainから返 すとエラーだとみなす。 12/02/11 Boost.勉強会 #8 大阪 21
  • 22. What's the Boost.Test? #include <iostream> #include <boost/test/included/prg_exec_monitor.hpp> int cpp_main(int, char* []) { std::cout << "Hello, worldn"; return 0; } 12/02/11 Boost.勉強会 #8 大阪 22
  • 23. What's the Boost.Test? #include <iostream> #include <boost/test/included/prg_exec_monitor.hpp> int cpp_main(int, char* []) { std::cout << "Hello, worldn"; return 0; } >./prg_exec_monitor_test.out Hello, world no errors detected 12/02/11 Boost.勉強会 #8 大阪 23
  • 24. What's the Boost.Test? Introduction What's ● Boost.Testとは Features How to use ● Execution Monitor Conclusion ● Program Execution Monitor ● Minimal Testing Facility ● Unit Test Framework の4つの機能 12/02/11 Boost.勉強会 #8 大阪 24
  • 25. What's the Boost.Test? Introduction What's ● Minimal Testing Facility テスト作成のための基本的な機能を Features ● How to use Conclusion 提供。 ● Testing toolsの一部を使用できる。 ● boost/test/minimal.hppをインクルー ドして、main関数の代わりに test_main関数からプログラムを開始 する。 12/02/11 Boost.勉強会 #8 大阪 25
  • 26. What's the Boost.Test? Introduction What's ● Minimal Testing Facility テスト作成のための基本的な機能を Features ● How to use Conclusion 提供。 ● Testing toolsの一部を使用できる。 ● boost/test/minimal.hppをインクルー ドして、main関数の代わりに test_main関数からプログラムを開始 する。 12/02/11 Boost.勉強会 #8 大阪 26
  • 27. What's the Boost.Test? Introduction What's ● Minimal Testing Facilityで提供されて Features いるTesting tools How to use Conclusion ● BOOST_CHECK(pred) – predがfalseならエラーレポートして継続 ● BOOST_REQUIRE(pred) – predがfalseならエラーレポートして中断 ● BOOST_ERROR(message) – エラーレポートして継続 ● BOOST_FAIL(message) – エラーレポートして中断 12/02/11 Boost.勉強会 #8 大阪 27
  • 28. What's the Boost.Test? Introduction What's ● Minimal Testing Facility ヘッダオンリーで使用できるので簡 Features ● How to use Conclusion 単。 ● 一応Unit Test Framework(UTF)の方もヘッダ オンリーにすることができる。 しかしUTFの方は長期的に使用する場合は スタンドアロンライブラリとしてリンクす ることが推奨される。 12/02/11 Boost.勉強会 #8 大阪 28
  • 29. What's the Boost.Test? #include <boost/test/minimal.hpp> int add(int i, int j) { return i*j; } int test_main(int, char *[]) { BOOST_CHECK( add(2, 2) == 4 ); BOOST_CHECK( add(2, 3) == 5 ); return 0; } >./minimal_test_test.out minimal_test_test.cpp(6): test add(2, 3) == 5 failed in function: 'int test_main(int, char**)' **** 1 error detected 12/02/11 Boost.勉強会 #8 大阪 29
  • 30. What's the Boost.Test? Introduction What's ● Boost.Testとは Features How to use ● Execution Monitor Conclusion ● Program Execution Monitor ● Minimal Testing Facility ● Unit Test Framework の4つの機能 12/02/11 Boost.勉強会 #8 大阪 30
  • 31. What's the Boost.Test? Introduction What's ● The Unit Test Framework(UTF) Features How to use ● Boost.Testのメイン機能 ヘッダオンリーあるいはスタンドア Conclusion ● ロンライブラリとして使用できる。 12/02/11 Boost.勉強会 #8 大阪 31
  • 32. What's the Boost.Test? Introduction What's ● Unit Testing Frameworkが満たすべ Features き要件 How to use Conclusion ● ユニットテストの作業は、プロジェ クトの実装初期からメンテナンス、 そして後々の改訂にいたるまで、ソ フトウェア開発のさまざまな段階で 発生する。 ● そのためUnit Testing Frameworkに 対して(時に衝突するような)多くの 性質が要求される 12/02/11 Boost.勉強会 #8 大阪 32
  • 33. Requirements of UTF ● シンプルで、使い始めの人にも分かりやすくユニットテ ストモジュールが書けるべき ● 上級者が自明でないようなテストをすることも可能であ るべき ● テストモジュールはたくさんの小さなテストケースを持 つことができ、開発者がそれをテストスイートにグルー プ化することができるべき ● 開発初期にはユーザーは詳細で説明的なエラーメッセー ジを見たい。しかし回帰テスト中にはどのテストが失敗 したかだけを知りたい。 12/02/11 Boost.勉強会 #8 大阪 33
  • 34. Requirements of UTF(Cont'd) ● 小さいテストモジュールの実行時間>コンパイル時間で あるべき。実行に1秒しかかからないテストのコンパイ ルに1分も待ちたくはない。 ● 長く複雑なテストではユーザーはテストの進捗を見られ るようにしたい。 ● 簡単なテストは外部ライブラリを必要とするべきではな い。 ● 長期的な使用のためにユニットテストフレームワークは スタンドアロンなライブラリとしてビルドできるべき。 12/02/11 Boost.勉強会 #8 大阪 34
  • 35. What's the Boost.Test? Introduction What's ● UTFの設計はこれらをベースにして Features いる。そしてUTFは多岐に渡る機能 を提供する How to use Conclusion ● さまざまなTesting toolsを使用することで簡 単にテストを書くことができる。 ● 一つのテストツリーの中にテストケースを組 織化できる。 ● 面倒なエラー検出とレポーティングの義務 とフレームワークの実行時パラメータ処理 からあなたを解放する。 などなど。ここらへんの話は http://www.boost.org/libs/test/doc/html/utf/intro.html に。 12/02/11 Boost.勉強会 #8 大阪 35
  • 36. What's the Boost.Test? 長い説明もつまらないのでちょっと Introduction ● What's Features 使ってみる。 How to use Conclusion 12/02/11 Boost.勉強会 #8 大阪 36
  • 37. What's the Boost.Test?   #define BOOST_TEST_MODULE SimpleTest #include <boost/test/unit_test.hpp> BOOST_AUTO_TEST_SUITE(simple_test_suite)   BOOST_AUTO_TEST_CASE(simple_test) { BOOST_CHECK_EQUAL(2+2, 4); }   BOOST_AUTO_TEST_SUITE_END() 12/02/11 Boost.勉強会 #8 大阪 37
  • 38. What's the Boost.Test? //テストモジュールの定義 #define BOOST_TEST_MODULE SimpleTest #include <boost/test/unit_test.hpp> //テストスイートの定義とテストモジュールへの追加 BOOST_AUTO_TEST_SUITE(simple_test_suite) //テストケースの定義とテストスイートへの追加 BOOST_AUTO_TEST_CASE(simple_test) { BOOST_CHECK_EQUAL(2+2, 4); } BOOST_AUTO_TEST_SUITE_END() 12/02/11 Boost.勉強会 #8 大阪 38
  • 39. What's the Features? 12/02/11 Boost.勉強会 #8 大阪 39
  • 40. What's the Features? Introduction What's ● Unit Test Frameworkの機能 Features How to use ● Usage Variant Conclusion ● テストランナー ● モジュール初期化関数 ● テストの作成と組織化 ● Fixture ● テストの出力 ● 実行時のテスト設定 ● Testing tools 12/02/11 Boost.勉強会 #8 大阪 40
  • 41. What's the Features? Introduction What's ● Unit Test Frameworkの機能 Features How to use ● Usage Variant Conclusion ● テストランナー ● モジュール初期化関数 ● テストの作成と組織化 ● Fixture ● テストの出力 ● 実行時のテスト設定 ● Testing tools 12/02/11 Boost.勉強会 #8 大阪 41
  • 42. What's the Features? Introduction What's ● Usage Variant Features How to use ● Testをする状況や環境に合わせて4 Conclusion 種類のUTFの使用法が用意されてい る。 12/02/11 Boost.勉強会 #8 大阪 42
  • 43. What's the Features? Introduction What's ● Usage Variant Features How to use ● Static Library Variant Conclusion ● UTFをスタティックリンクする構成 ● Macでは使えない・・・? http://d.hatena.ne.jp/kei10in/20100623/1277294693 12/02/11 Boost.勉強会 #8 大阪 43
  • 44. What's the Features? Introduction What's ● Usage Variant Features How to use ● Dynamic Library Variant Conclusion ● UTFをダイナミックリンクする構成 ● #define BOOST_TEST_DYN_LINK ● (メインになる)ただひとつのソースの boost/test/unit_test.hppの、そのインクルー ド前にBOOST_TEST_MAINを定義する。 あるいはBOOST_TEST_MODULEを使用し てもOK。 12/02/11 Boost.勉強会 #8 大阪 44
  • 45. What's the Features? Introduction What's ● Usage Variant Features How to use ● Dynamic Library Variant Conclusion ● Static Library Variantを使用すると バイナリが大きくなるので、Static Library Variantを使用した大量のテ ストのプロジェクトがあるとスト レージの容量的な問題が起こるか も。その場合にはDynamic Library Variantを使用したほう良い。 12/02/11 Boost.勉強会 #8 大阪 45
  • 46. What's the Features? Introduction What's ● Usage Variant Features How to use ● Single-Header Variant Conclusion ● UTFをヘッダオンリーにする構成 ● テストモジュールのソースがひとつ だけの時使える。 ● (コンパイル時間を考えると)長期 的な使用にはスタティックリンクか ダイナミックリンクを使用するべき ● #include <boost/test/included/unit_test.hpp> 12/02/11 Boost.勉強会 #8 大阪 46
  • 47. What's the Features? Introduction What's ● Usage Variant Features How to use ● External Test Runner Variant ビルトインではないテストランナー Conclusion ● を使用する構成 ● テストモジュールはダイナミックリ ンクライブラリとして作成する ● #define BOOST_TEST_DYN_LINK 12/02/11 Boost.勉強会 #8 大阪 47
  • 48. What's the Features? Introduction What's ● Unit Test Frameworkの機能 Features How to use ● Usage Variant Conclusion ● テストランナー ● モジュール初期化関数 ● テストの作成と組織化 ● Fixture ● テストの出力 ● 実行時のテスト設定 ● Testing tools 12/02/11 Boost.勉強会 #8 大阪 48
  • 49. What's the Features? テストランナー(Test Runner) Introduction ● What's テストの実行を管理する Features ● How to use Conclusion ● テストモジュールのエントリポイント ● 実行時パラメータ(コマンドライン引数など) からUTFを初期化する ● ログとテストのレポート用にOutputを準備 ● などなど・・・ 12/02/11 Boost.勉強会 #8 大阪 49
  • 50. What's the Features? テストランナー(Test Runner) Introduction ● What's ビルトイン以外のテストランナーを Features ● How to use Conclusion 使用することができる。 (先進的なテストランナーはGUIや テストカバレッジの機能を備えてい るかも) (でも見たことない) ● 今日は扱いません。あとよく分かり ません。 語りえぬものについては、沈黙しなければ ならない 12/02/11 Boost.勉強会 #8 大阪 50
  • 51. What's the Features? Introduction What's ● Unit Test Frameworkの機能 Features How to use ● Usage Variant Conclusion ● テストランナー ● モジュール初期化関数 ● テストの作成と組織化 ● Fixture ● テストの出力 ● 実行時のテスト設定 ● Testing tools 12/02/11 Boost.勉強会 #8 大阪 51
  • 52. What's the Features? モジュール初期化関数 Introduction ● What's テストツリーを構築するなど…? Features ● How to use ほとんどビルトインのもので済むの Conclusion ● で使わなくても大丈夫 ● 今日は扱いません。あとよく分かり ません。 語りえぬものについては、沈黙しなければ ならない 12/02/11 Boost.勉強会 #8 大阪 52
  • 53. What's the Features? Introduction What's ● Unit Test Frameworkの機能 Features How to use ● Usage Variant Conclusion ● テストランナー ● モジュール初期化関数 ● テストの作成と組織化 ● Fixture ● テストの出力 ● 実行時のテスト設定 ● Testing tools 12/02/11 Boost.勉強会 #8 大阪 53
  • 54. What's the Features? テストの定義と組織化 Introduction ● What's Features How to use Conclusion ● テストケースを作成 ● テストケースをテストスイートにグ ループ化できる ● テストスイートをさらに大きなテス トスイートにグループ化できる 12/02/11 Boost.勉強会 #8 大阪 54
  • 55. What's the Boost.Test?( 再掲 ) //テストモジュールの定義 #define BOOST_TEST_MODULE SimpleTest #include <boost/test/unit_test.hpp> //テストスイートの定義とテストモジュールへの追加 BOOST_AUTO_TEST_SUITE(simple_test_suite) //テストケースの定義とテストスイートへの追加 BOOST_AUTO_TEST_CASE(simple_test) { BOOST_CHECK_EQUAL(2+2, 4); } BOOST_AUTO_TEST_SUITE_END() 12/02/11 Boost.勉強会 #8 大阪 55
  • 56. What's the Features? テストの定義と組織化 Introduction ● What's Features How to use ● BOOST_AUTO_TEST_CASE( Conclusion test_case_name ) ● 引数なしテストケースを定義する BOOST_AUTO_TEST_CASE(test_case_name) { BOOST_AUTO_TEST_CASE(test_case_name) { //test body //test body } } ● 手動でテストケースの登録を行う場合は、引 数付きのテストケースを使うことができる。 12/02/11 Boost.勉強会 #8 大阪 56
  • 57. What's the Features? テストの定義と組織化 Introduction ● What's Features How to use ● BOOST_AUTO_TEST_CASE_TEMPLATE( Conclusion test_case_name, formal_type_parameter_name, collection_of_types ) ● テンプレートを使用したテストケー スを定義する ● 同じ内容で型のみが異なるテストを 書くときに便利 12/02/11 Boost.勉強会 #8 大阪 57
  • 58. What's the Features? テストの定義と組織化 Introduction ● What's Features How to use ● BOOST_AUTO_TEST_SUITE( Conclusion test_suite_name ) ● テストスイートを定義する BOOST_AUTO_TEST_SUITE(test_suite_name) BOOST_AUTO_TEST_SUITE(test_suite_name) // some tests // some tests // BOOST_AUTO_TEST_CASE(test1) // BOOST_AUTO_TEST_CASE(test1) // { /**/ } // { /**/ } BOOST_AUTO_TEST_SUITE_END() BOOST_AUTO_TEST_SUITE_END() 12/02/11 Boost.勉強会 #8 大阪 58
  • 59. What's the Features? テストの定義と組織化 Introduction ● What's テストケースはテストスイートのなか Features ● に複数含めることができる。 How to use Conclusion ● テストスイートは入れ子になること ができる。 12/02/11 Boost.勉強会 #8 大阪 59
  • 60. What's the Boost.Test? #include <boost/test/unit_test.hpp> BOOST_AUTO_TEST_SUITE(suite1) BOOST_AUTO_TEST_SUITE(suite2) BOOST_AUTO_TEST_CASE(test1) { /**/ } BOOST_AUTO_TEST_CASE(test2) { /**/ } BOOST_AUTO_TEST_SUITE_END() BOOST_AUTO_TEST_CASE(test3) { /**/ } BOOST_AUTO_TEST_SUITE_END() 12/02/11 Boost.勉強会 #8 大阪 60
  • 61. What's the Boost.Test? Master Test Suite Master Test Suite suite1 suite1 suite2 suite2 test3 test3 test2 test2 test1 test1 12/02/11 Boost.勉強会 #8 大阪 61
  • 62. What's the Features? Introduction What's ● Unit Test Frameworkの機能 Features How to use ● Usage Variant Conclusion ● テストランナー ● モジュール初期化関数 ● テストの作成と組織化 ● Fixture ● テストの出力 ● 実行時のテスト設定 ● Testing tools 12/02/11 Boost.勉強会 #8 大阪 62
  • 63. What's the Features? Introduction What's ● Fixture テストケースなどで以下の役割を担 Features ● How to use Conclusion う ● テスト開始前に状態を整える ● テストに関する特定の状態を用意する ● テスト終了後にクリーンアップをする 12/02/11 Boost.勉強会 #8 大阪 63
  • 64. What's the Features? Introduction What's ● Generic Fixture Model Features How to use Conclusion struct <fixture-name>{ struct <fixture-name>{ <fixture-name>(); // setup function <fixture-name>(); // setup function ~<fixture-name>(); // teardown function ~<fixture-name>(); // teardown function }; }; 12/02/11 Boost.勉強会 #8 大阪 64
  • 65. What's the Boost.Test? //Fixtureを使ったテストの例 struct MyFixture { MyFixture() { i = new int; *i = 0 } ~ MyFixture() { delete i; } int * i; }; BOOST_AUTO_TEST_CASE( test_case1 ) { MyFixture f; // do something involving f.i } 12/02/11 Boost.勉強会 #8 大阪 65
  • 66. What's the Boost.Test? //Fixtureを使ったテストの例 struct MyFixture { MyFixture() { i = new int; *i = 0 } ~ MyFixture() { delete i; } int * i; }; BOOST_AUTO_TEST_CASE( test_case1 ) { MyFixture f; // do something involving f.i } 12/02/11 Boost.勉強会 #8 大阪 66
  • 67. What's the Boost.Test? struct MyFixture { MyFixture() { i = new int; *i = 0 } ~ MyFixture() { delete i; } int * i; }; BOOST_FIXTURE_TEST_CASE( test_case1, MyFixture ) { // do something involving i } // test_cast1を開始する前にMyFixtureを構築して、 // test_case1が終わるとMyFixtureを破棄する 12/02/11 Boost.勉強会 #8 大阪 67
  • 68. What's the Features? Introduction What's ● Fixture テストケースなどで以下の役割を担 Features ● How to use Conclusion う ● テスト開始前に状態を整える ● テストに関する特定の状態を用意する ● テスト終了後にクリーンアップをする 12/02/11 Boost.勉強会 #8 大阪 68
  • 69. What's the Features? Introduction What's ● Fixture Features How to use ● 3つのレベルでSetupとCleanupを行 Conclusion うことができる ● テストケース ● テストスイート ● グローバル 12/02/11 Boost.勉強会 #8 大阪 69
  • 70. What's the Features? Introduction What's ● Fixtureの設定 Features How to use ● BOOST_FIXTURE_TEST_CASE( Conclusion test_case_name, fixure_name) ● テストケースごとのFixtureを設定 12/02/11 Boost.勉強会 #8 大阪 70
  • 71. What's the Features? Introduction What's ● Fixtureの設定 Features How to use ● BOOST_FIXTURE_TEST_SUITE( Conclusion test_suite_name, fixure_name) ● テストスイートごとのFixtureを設定 ● テストスイート内の各テストケース が同じFixtureを使用したいときの為 にテストスイートレベルでFixtureを 使用できる。 12/02/11 Boost.勉強会 #8 大阪 71
  • 72. What's the Features? Introduction What's ● Fixtureの設定 Features How to use ● BOOST_GLOBAL_FIXTURE( Conclusion fixure_name) ● グローバルなFixtureを設定 ● テストの開始時の初期化を担う ● テスト用の各ソースファイルに複数 の別のグローバルなFixtureを設定す ることも可能 12/02/11 Boost.勉強会 #8 大阪 72
  • 73. What's the Features? Introduction What's ● Fixtureの設定 Features How to use ● BOOST_GLOBAL_FIXTURE( Conclusion fixure_name) ● グローバルなFixtureを設定 ● テストの開始時の初期化を担う ● テスト用の各ソースファイルに複数 の別のグローバルなFixtureを設定す ることも可能 ● でもデストラクト順が厄介・・・? 12/02/11 Boost.勉強会 #8 大阪 73
  • 74. What's the Boost.Test? struct F1 { F1() { std::cout << "F1" << std::endl; } ~F1() { std::cout << "~F1" << std::endl; } }; //同様にF2, F3を定義する 12/02/11 Boost.勉強会 #8 大阪 74
  • 77. What's the Features? Introduction What's ● Unit Test Frameworkの機能 Features How to use ● Usage Variant Conclusion ● テストランナー ● モジュール初期化関数 ● テストの作成と組織化 ● Fixture ● テストの出力 ● 実行時のテスト設定 ● Testing tools 12/02/11 Boost.勉強会 #8 大阪 77
  • 78. What's the Features? テストの出力 Introduction ● What's 全てのテストで統一的なレポートを Features ● How to use Conclusion ● エラーについて、ソース上の詳細な 情報を ● テストのエラーの記述(test log)はテ スト結果の要約(test results report) とは分離する ● 柔軟な出力内容 ● 柔軟な出力の形式 12/02/11 Boost.勉強会 #8 大阪 78
  • 79. What's the Features? テストの出力 Introduction ● What's Features How to use ● Test Log Conclusion ● Test Report ● Progress Display 12/02/11 Boost.勉強会 #8 大阪 79
  • 80. What's the Features? テストの出力 Introduction ● What's Features How to use ● Test Log Conclusion ● Test Report ● Progress Display 12/02/11 Boost.勉強会 #8 大阪 80
  • 81. What's the Features? テストの出力 Introduction ● What's Features How to use ● Test Logのレベル Conclusion ● Success information messages ● Test tree traversal notifications ● General information messages ● Warning messages ● Non fatal error messages ● Uncaught C++ exceptions notifications ● Non-fatal system error ● Fatal system error 12/02/11 Boost.勉強会 #8 大阪 81
  • 82. What's the Features? テストの出力 Introduction ● What's Features How to use ● Test Logのレベル 各レベルは下のレベルの内容を含む Conclusion ● ● デフォルトはNon fatal error messages ● 各レベルの詳細は http://www.boost.org/libs/test/doc/html/utf/user-guide/test-output/test-log.htm を参照。 12/02/11 Boost.勉強会 #8 大阪 82
  • 83. What's the Features? テストの出力 Introduction ● What's Features How to use ● operator<<のインターフェースを持 Conclusion たない型がlogに出力されようとした ときはコンパイルエラーになる。 ● そのコンパイルエラーを避ける場 合、あるいはlogに出力したくない場 合は BOOST_TEST_DONT_PRINT_LOG_VALUE( ArgumentType ) を使用する 12/02/11 Boost.勉強会 #8 大阪 83
  • 84. What's the Features? テストの出力 Introduction ● What's Features How to use BOOST_TEST_MESSAGE( Conclusion test_message ) ● Logにメッセージをさしこむ ● ただし、デフォルトのLogレベルの 設定では出力されない ● LogレベルをGeneral information messages 以上にする 12/02/11 Boost.勉強会 #8 大阪 84
  • 85. What's the Features? テストの出力 Introduction ● What's Features How to use ● Test Logのレベル 各レベルの詳細は Conclusion ● http://www.boost.org/libs/test/doc/html/utf/user-guide/test-output/test-log.html を参照。 12/02/11 Boost.勉強会 #8 大阪 85
  • 86. What's the Features? テストの出力 Introduction ● What's Features How to use BOOST_TEST_CHECKPOINT( Conclusion checkpoint_message) ● Logに名前付きのチェックポイント をさしこむ 12/02/11 Boost.勉強会 #8 大阪 86
  • 87. What's the Features? テストの出力 Introduction ● What's Features How to use ● Logの出力フォーマット Conclusion ● Human Readable – Microsoft系C++コンパイラのエ ラー記述に似た形式でLogを出 力 ● XML – XML形式でLogを出力 12/02/11 Boost.勉強会 #8 大阪 87
  • 88. What's the Features? テストの出力 Introduction ● What's Features How to use ● Logの出力先をコンパイル時に設定 Conclusion unit_test_log.set_stream( std::ostream& str ); 12/02/11 Boost.勉強会 #8 大阪 88
  • 89. What's the Boost.Test? struct MyConfig { MyConfig() : test_log( "example.log" ) { boost::unit_test::unit_test_log.set_stream( test_log ); } ~MyConfig() { boost::unit_test::unit_test_log.set_stream( std::cout ); } std::ofstream test_log; }; BOOST_GLOBAL_FIXTURE( MyConfig ); BOOST_AUTO_TEST_CASE( test_case ) { //... 12/02/11 Boost.勉強会 #8 大阪 89
  • 90. What's the Features? テストの出力 Introduction ● What's Features How to use ● Log出力のレベルをコンパイル時に Conclusion 設定する unit_test_log.set_threshold_level( boost::unit_test::log_level ); 12/02/11 Boost.勉強会 #8 大阪 90
  • 91. What's the Features? using namespace boost::unit_test; BOOST_AUTO_TEST_CASE( test_case0 ) { if ( runtime_config::log_level() < log_warnings ) unit_test_log.set_threshold_level( log_warnings ); BOOST_WARN( sizeof(int) > 4 ); } 12/02/11 Boost.勉強会 #8 大阪 91
  • 92. What's the Features? テストの出力 Introduction ● What's Features How to use ● Test Log Conclusion ● Test Report ● Progress Display 12/02/11 Boost.勉強会 #8 大阪 92
  • 93. What's the Features? テストの出力 Introduction ● What's テストレポートの出力 Features ● How to use Conclusion ● Runtime configuration ● Compile time configuration ● Report output stream redirection and access ● Report level configuration ● Predefined report format selection ● Custom report format support 12/02/11 Boost.勉強会 #8 大阪 93
  • 94. What's the Features? テストの出力 Introduction ● What's テストレポートの出力 Features ● How to use Conclusion ● Runtime configuration ● Compile time configuration ● Report output stream redirection and access ● Report level configuration ● Predefined report format selection ● Custom report format support ● ドキュメントに詳細がない・・・? 12/02/11 Boost.勉強会 #8 大阪 94
  • 95. What's the Features? テストの出力 Introduction ● What's Features How to use ● Test Log Conclusion ● Test Report ● Progress Display 12/02/11 Boost.勉強会 #8 大阪 95
  • 96. What's the Features? テストの出力 Introduction ● What's Features How to use ● Progress Display 次に紹介する実行時設定 Conclusion ● show_progress を使用する。 > example --show_progress=yes --log_level=nothing 0% 10 20 30 40 50 60 70 80 90 100% |----|----|----|----|----|----|----|----|----|----| *************************************************** *** No errors detected 12/02/11 Boost.勉強会 #8 大阪 96
  • 97. What's the Features? Introduction What's ● Unit Test Frameworkの機能 Features How to use ● Usage Variant Conclusion ● テストランナー ● モジュール初期化関数 ● テストの作成と組織化 ● Fixture ● テストの出力 ● 実行時のテスト設定 ● Testing tools 12/02/11 Boost.勉強会 #8 大阪 97
  • 98. What's the Features? 実行時のテスト設定 Introduction ● What's 環境変数、あるいは実行時引数でロ Features ● グ出力の挙動を設定する How to use Conclusion ● auto_start_dbg ● build_info ● catch_system_errors ● detect_memory_leak ● detect_fp_exceptions 12/02/11 Boost.勉強会 #8 大阪 98
  • 99. What's the Features? 実行時のテスト設定 Introduction ● What's 環境変数、あるいは実行時引数でロ Features ● グ出力の挙動を設定する How to use Conclusion ● log_format ● log_level ● output_format ● random ● report_format 12/02/11 Boost.勉強会 #8 大阪 99
  • 100. What's the Features? 実行時のテスト設定 Introduction ● What's 環境変数、あるいは実行時引数でロ Features ● グ出力の挙動を設定する How to use Conclusion ● report_level ● result_code ● run_test ● show_progress ● use_alt_stack 12/02/11 Boost.勉強会 #8 大阪 100
  • 101. What's the Features? Introduction What's ● Unit Test Frameworkの機能 Features How to use ● Usage Variant Conclusion ● テストランナー ● モジュール初期化関数 ● テストの作成と組織化 ● Fixture ● テストの出力 ● 実行時のテスト設定 ● Testing tools 12/02/11 Boost.勉強会 #8 大阪 101
  • 102. What's the Features? Testing tools Introduction ● What's Minimal Testing Facilityの例で使 Features ● 用したBOOST_CHECKなど How to use Conclusion 12/02/11 Boost.勉強会 #8 大阪 102
  • 103. What's the Features? Testing tools Introduction ● What's 複数のマクロと関数宣言からなる Features ● ツール集。 How to use Conclusion ● テストの作成と管理を容易にして、 統一的なエラーレポーティングの仕 組みを提供する。 ● 全てのツールは自動的にエラーレ ポーティングにエラーの位置情報 (ファイル名と行番号) 12/02/11 Boost.勉強会 #8 大阪 103
  • 104. What's the Features? Testing tools flavors Introduction ● What's 全てのテストツールにはflavorsが提 Features ● 供されている How to use Conclusion ● テストツールのアサーションについ てのレベル的なもの 12/02/11 Boost.勉強会 #8 大阪 104
  • 105. What's the Features? Testing tools flavors Introduction ● What's WARN Features ● How to use Conclusion ● 警告 ● エラーカウント:そのまま ● テストの実行:継続 12/02/11 Boost.勉強会 #8 大阪 105
  • 106. What's the Features? Testing tools flavors Introduction ● What's CHECK Features ● How to use Conclusion ● エラーチェック ● エラーカウント:増加 ● テストの実行:継続 12/02/11 Boost.勉強会 #8 大阪 106
  • 107. What's the Features? Testing tools flavors Introduction ● What's REQUIRE Features ● How to use Conclusion ● 必要条件チェック ● エラーカウント:増加 ● テストの実行:中断 12/02/11 Boost.勉強会 #8 大阪 107
  • 108. What's the Features? 提供されているTesting tools Introduction ● What's BOOST_<level> Features ● How to use Conclusion BOOST_CHECK( i == 1 ); BOOST_CHECK( i == 1 ); BOOST_REQUIRE( !str.empty() ); BOOST_REQUIRE( !str.empty() ); Running 1 test case... testing_tool_test.cpp:10: error in "testing_tool_test": check i == 1 failed testing_tool_test.cpp:11: fatal error in "testing_tool_test": critical check !str.empty() failed *** 2 failures detected in test suite "Master Test Suite" 12/02/11 Boost.勉強会 #8 大阪 108
  • 109. What's the Features? 提供されているTesting tools Introduction ● What's BOOST_<level>_EQUAL Features ● How to use Conclusion BOOST_CHECK_EQUAL( i, 1 ); BOOST_CHECK_EQUAL( i, 1 ); BOOST_REQUIRE_EQUAL( str, “STRING” ); BOOST_REQUIRE_EQUAL( str, “STRING” ); Running 1 test case... testing_tool_test.cpp:10: error in "testing_tool_test": check i == 1 failed [0 != 1] testing_tool_test.cpp:11: fatal error in "testing_tool_test": critical check str == "STRING" failed [ != STRING] *** 2 failures detected in test suite "Master Test Suite" 12/02/11 Boost.勉強会 #8 大阪 109
  • 110. What's the Features? 提供されているTesting tools Introduction ● What's などなど・・・ Features ● How to use Conclusion ● 詳しくはドキュメントに書いてあり ます。 12/02/11 Boost.勉強会 #8 大阪 110
  • 111. What's the Features? 提供されているTesting tools Introduction ● What's Testing toolsを使うことでテストの Features ● 意味を分かりやすく書くことがで How to use Conclusion き、さらに統一的なエラーレポー ティングができるようになる。 12/02/11 Boost.勉強会 #8 大阪 111
  • 112. How to use the Boost.Test 12/02/11 Boost.勉強会 #8 大阪 112
  • 113. How to use the Boost.Test デモ Introduction ● What's Features How to use Conclusion 12/02/11 Boost.勉強会 #8 大阪 113
  • 114. Conclusion 12/02/11 Boost.勉強会 #8 大阪 114
  • 115. Conclusion Introduction What's ● Boost.Testを使うことで、C++のテ Features ストを自動的に組織しながらテスト How to use Conclusion を書くことができる。 ● 実行時引数を設定することで、柔軟 にテストをすることができる。 ● Testing toolsを使うことでテスト内 容を明確にすることができる。 ● (Boostに含まれてるので)普段から Boostを使っている人は導入しやす い。 12/02/11 Boost.勉強会 #8 大阪 115
  • 116. Conclusion 欠点 Introduction ● What's 実行時にスキップするテストを選ぶ Features ● ことが出来ない How to use Conclusion ● Mockの仕組みがない ● テスト出力のストリームがワイド文 字列対応していない 12/02/11 Boost.勉強会 #8 大阪 116
  • 117. Conclusion 欠点 Introduction ● What's 実行時にスキップするテストを選ぶ Features ● ことが出来ない How to use Conclusion ● Mockの仕組みがない ● テスト出力のストリームがワイド文 字列対応していない 12/02/11 Boost.勉強会 #8 大阪 117
  • 118. Conclusion Introduction What's ● Mockの仕組みがない Features http://alexott.net/en/cpp/CppTestingIntro.html How to use Conclusion ● ここにGoogle MockとBoost.Testを 組み合わせたテストの紹介がありま す。 12/02/11 Boost.勉強会 #8 大阪 118
  • 119. Conclusion Introduction What's ● Mockの仕組みがない アンドキュメントだがあるらし Features ● How to use Conclusion い・・・?(@cpp_akiraさん情報ありがとうございます) ● see boost/libs/test/example/example/est_example1.cpp ● see boost/libs/test/example/example/est_example2.cpp 12/02/11 Boost.勉強会 #8 大阪 119
  • 120. Conclusion 参考文献/サイト Introduction ● What's Features ● http://www.boost.org/libs/test/doc/html/ How to use ● http://alexott.net/en/cpp/CppTestingIntro.html Conclusion ● http://www.alittlemadness.com/2009/03/31/c-unit-testing-with-boosttest/ ● http://blog.livedoor.jp/naoya_t/archives/51043392.html 12/02/11 Boost.勉強会 #8 大阪 120
  • 121. Conclusion 質問など・・・ Introduction ● What's Features How to use Conclusion 12/02/11 Boost.勉強会 #8 大阪 121
  • 122. Thank You! ありがとうございました! 12/02/11 Boost.勉強会 #8 大阪 122