This guide provides step-by-step instructions for creating, executing, and verifying Code-Based Tests in a C++ project.
1. Preparing the Project
Code-Based Test requires a C++ project that meets the following conditions.
Requirements | Description |
---|---|
Project Type | C++ project (C projects are not supported) |
Supported Toolchains | GCC 5.0 or later Visual Studio 2015 or later Clang 8.0 or later |
Execution Environment | Host Environment (Target Environment is not supported) |
2. Creating Tests
- Create tests using one of the following two methods.
- When the test creation dialog opens, enter the following information.
- Click [OK] to create the test file. The generated test is automatically added to the [Code-Based Test View].
3. Writing Test Code
- Write test code using macros such as
EXPECT_EQ
andASSERT_TRUE
to verify that the function behaves as expected.
- If the TEST macro syntax is incorrect or the file contains GTest macros not supported by CT, an error marker appears in the left column when the file is saved. After checking the error message, correct the invalid syntax and replace unsupported macros with those supported by CT.
4. Executing Tests
- After test execution, view the logs of the executed test cases in the [Console View]. Test logs are available in the [Console View]. Logs are not displayed if the view is closed.
5. Checking Test Results and Coverage
Check the test results and coverage in the following locations.
- [Code-Based Test View]: Test structure and pass/fail status
- [Console View]: Execution logs for each test case
- [Coverage View]: Coverage information for functions called during test execution
Need more help with this?
Don’t hesitate to contact us here.