> For the complete documentation index, see [llms.txt](https://dwatow.gitbook.io/cppunit-cookbook-in-traditional-chinese/llms.txt). Markdown versions of documentation pages are available by appending `.md` to page URLs; this page is available as [Markdown](https://dwatow.gitbook.io/cppunit-cookbook-in-traditional-chinese/post-build_check.md).

# Post-build check

終於，這一刻我們擁有了會執行的unit test程式了，那要 怎麼整合unit test到開發專案的build process呢？

為了做到一點，開發專案必須回傳一個不同於0的值，表示程式出錯。

TestRunner::run()回傳一個boolean值，代表執行成功。

更新我們的測試主程式，如下:

```
#include <cppunit/extensions/TestFactoryRegistry.h>
#include <cppunit/ui/text/TestRunner.h>

int main( int argc, char **argv)
{
  CppUnit::TextUi::TestRunner runner;
  CppUnit::TestFactoryRegistry &registry = CppUnit::TestFactoryRegistry::getRegistry();
  runner.addTest( registry.makeTest() );
  bool wasSucessful = runner.run( "", false );  //update this
  return wasSucessful;
}
```

現在，你所需要做的，就是編譯並執行程式。

在Visual C++，開啟`Project Settings>Post-Build`，並且加上`$(TargetPath)`，擴充測試專案執行路徑。使用這個技術實例可以參考這個專案 `examples/cppunittest/CppUnitTestMain.dsp`。

原作Michael Feathers，Doxygen改版，Baptiste Lepilleur更新。

正體中文版翻譯: kx

## 譯註

* `$(TargetPath)`與其相關內容參考自簡體中文版的cppunit cookbook。
