CppUnitをVC++で使用する方法

はじめに

CppUnitの準備

  1. Source Forgeからcppunit-xxxx.zipファイルを取得します。
  2. 適当なフォルダ,例えばC:\cppunit-x-20020331などに展開します。
  3. C:\cppunit-x-20020331\msvc\cppunit.dswを開いてビルドし,cppunit.libを作ります。

テスト

  1. CppUnit 入門サイトにて配布されているdicegame-0.2.zipを例に説明します。
  2. 同ファイルを展開し,dicegame-0.2\msvc\dicegame.dswを開きます。
  3. 古い形式を新しい形式に変換するかどうか聞かれるのですべてイエスと答えます。
  4. ソリューションエクスプローラのdicegate_testsのコンテキストメニューでプロパティを選択します。
  5. 構成プロパティのC/C++の全般で,追加のインクルードディレクトリにC:\cppunit-x-20020331を入力します。
  6. 構成プロパティのリンカの入力で,追加の依存ファイルにC:\cppunit-x-20020331/msvc/cppunit.libを追加します。
  7. ソリューションをビルドするとdicegame-0.2\msvc\dicegame_tests\Debugにdicegame_tests.exeが生成されます。
  8. cmdから実行すると以下の出力が得られます。
    D:\>dicegame_tests.exe
    .F
    .F
    .F
    
    
    !!!FAILURES!!!
    Test Results:
    Run: 3, Failures: 3, Errors: 0
    There were 3 failures:
    1) DiceGamePlayerTest::testCreate (dicegameplayertest.cpp:16)
    expected:<0> but was:<-858993460>
    2) DiceGamePlayerTest::testWinGame (dicegameplayertest.cpp:27)
    expected:<0> but was:<-858993460>
    3) DiceGamePlayerTest::testLoseGame (dicegameplayertest.cpp:37)
    expected:<0> but was:<-858993460>

トップ   新規 一覧 検索 最終更新   ヘルプ   最終更新のRSS