# Suite

如何配置才可以自動執行所有的測試。

CppUnit提供`TestSuite`類別，它可以自動執行多個test case。

上述我們知道，如何執行一個test case。

那要怎麼建立一個test suite將多個test case裝起來，可以跟著下列的操作:

```
CppUnit::TestSuite suite;
CppUnit::TestResult result;
suite.addTest(
    new CppUnit::TestCaller<ComplexNumberTest>
    ("testEquality", &ComplexNumberTest::testEquality) );
suite.addTest(
    new CppUnit::TestCaller<ComplexNumberTest>
    ("testAddition", &ComplexNumberTest::testAddition) );
suite.run( &result );
```

TestSuites不只包含呼叫TestCas的TestCaller。他們可以包含任何實作`Test`介面的物件。 例如，你在你的程式建立一個`TestSuite`，而我可以建立我的，我們可以透過`TestSuite`讓它們可以一起依序執行:

```
CppUnit::TestSuite suite;
CppUnit::TestResult result;
suite.addTest( ComplexNumberTest::suite() );
suite.addTest( SurrealNumberTest::suite() );
suite.run( &result );
```

## 關鍵字翻譯:

* test suite 測試套件
* test case 測試案例


---

# Agent Instructions: Querying This Documentation

If you need additional information that is not directly available in this page, you can query the documentation dynamically by asking a question.

Perform an HTTP GET request on the current page URL with the `ask` query parameter:

```
GET https://dwatow.gitbook.io/cppunit-cookbook-in-traditional-chinese/suite.md?ask=<question>
```

The question should be specific, self-contained, and written in natural language.
The response will contain a direct answer to the question and relevant excerpts and sources from the documentation.

Use this mechanism when the answer is not explicitly present in the current page, you need clarification or additional context, or you want to retrieve related documentation sections.
