Why VectorCAST/C++ for C and C++ Unit Testing?
Generally, software component testing requires at least one line of test code (in the form of stubs or mocks, drivers, and test data) for each line of C or C++ code to be tested. Manually creating these test frameworks can be expensive and inefficient because engineers need to write and debug the test code as well as the application code. With VectorCAST/C++, the mocking framework is generated automatically and component testing can be performed without writing a single line of test code, freeing time to build comprehensive test cases, debug issues and finalize the code. Writing unit tests is as easy as selecting input and expected results for the unit under test (UUT) from an easy-to-use interface. Test specific user code can also be added to the test harness. For instance, user code can be added to support teardown requirements. The mocking framework includes support for C++ mocking. Initialization test cases can be used to create objects in a C++ class, calling the class constructors to initialize objects.
Integrated Code Coverage
Without a code coverage tool, it is difficult to determine which portions of your source code have been exercised during testing. VectorCAST/C++ provides an integrated code coverage utility that allows you to gauge the effectiveness of your component testing by reporting on the source code statements or decision points exercised during individual or multiple test runs. Code coverage data can also be shared with VectorCAST/QA to produce combined coverage reports that reflect unit, integration, and system testing. Because VectorCAST/QA can also provide code coverage from your existing CPPUnit, GoogleTest or other unit testing frameworks, a complete view of code coverage across all phases of testing and all testing tools is possible. This aggregated code coverage can provide actionable insight into where testing efforts should focus. This is particularly effective when code coverage data is generated using VectorCAST/QA on legacy code, which doesn't have a formal unit test suite.
Testing is Repeatable
Since VectorCAST provides an automated C and C++ unit testing framework that doesn't have to be manually maintained, you can use it to make repeat testing more efficient. You can use your VectorCAST/C++ test project as a test runner to automatically rerun the test cases against the latest version of your C or C++ source files. These tests are easily executable against successive versions of your code. The management of test execution and the cataloging of test results are automatic. Comparing results of the same test cases against new software versions, prior to system integration is easy, with clearly outlined results, organized by date, time, unit and test names. This reporting results in fewer surprises caused by “one small change” to a software component. This is essential for companies wishing to develop software using a continuous integration and test process.
Supports Integration Testing
Multiple units can be tested in a single VectorCAST/C++ test environment. The VectorCAST/C++ unit test framework allows you to create complex test cases and scenarios that stimulate multiple functions across multiple units. Thorough integration testing is necessary for simulating real-world scenarios and ensuring proper functionality. Integration testing with VectorCAST/C++ allows dependencies to be stubbed or to be included as real code.
Data Capture and Control Flow
VectorCAST/C++ supports the use of Probe Points, which allow for run-time changes to data or control flow to support testing. This allows the test case to automatically drive the code down a hard-to-reach path. Asserts can also be used to capture the state of the code at a specific point in time. When the assert is evaluated during test execution, an event is logged in in the Execution Results report along with whether the assert was true or false. Probe points can also be used on function exit to add custom teardown code.
VectorCAST/C++ automatically compiles and links all of its generated test harness components using your compiler. An interface to your compiler’s debugger is also provided so that you can run test cases under the control of the debugger, making it easier to debug issues.
Test-Driven Development (TDD)
VectorCAST/C++ supports Agile and Test Driven Development methodologies. Once the design is complete, you can focus on test case development. This allows you to construct all unit tests based simply on the header files, prior to developing any application code. Early in this process, unit tests will fail due to the absence of source code. However, with the incremental development of code for individual units, the unit tests will begin to pass as less stubs or mocks and more real code is used. After this process, the unit test suite can be regression tested automatically.
Embedded Target Testing
VectorCAST/C++, when used in conjunction with VectorCAST RSP, allows C and C++ unit testing directly on your embedded target system. VectorCAST RSP is integrated with your specific cross compiler and RTOS, making it the perfect tool for testing real-time applications. Test cases may be developed in a host environment and then re-executed on an embedded target to verify real-world target and cross-compiler performance. This ability to compile and run the software executable in a real-world environment helps build confidence in the application.
VectorCAST/C++ is designed to work with your existing software development toolchain and build system. You can build your software using common development environments like Windows Visual Studio, cmake or Github, allowing you to work based on already established workflows. Better yet, your test projects are executable in multiple environments and VectorCAST/C++ will use the compiler, operating system, and hardware appropriate for that environment. This means you can use VectorCAST/C++ for both host-based development testing, using Visual Studio for instance, as well as testing in your final embedded hardware target environment. This provides real-world testing scenarios that ensure the best possible functionality for your software. Python scripts can also be used to integrate VectorCAST with other tools in your development environment.
Data API and Reporting
VectorCAST/C++ has a compete data API that allows you to build your own custom reports. The data API also allows advanced customization of VectorCAST via the development of Python scripts that provide advanced analysis based on the VectorCAST data. Some reports are also available in xml format including the Probe Points Report which produces a list of probe points which can be parsed and passed to a third party tool managing the probe points.