How spektralcpp/tests works
Main Components
• TestCase: Representing an individual test, defined in TestCase.hpp. This component encapsulates the expected and actual values and handles the execution (“run()”) of a single test.
• AssertionGroup (or TestGroup): Defined in TestGroup.hpp, this component groups together multiple TestCases that are related to a specific function. It provides a means for running and reporting on all tests for that function.
• TestSuite: Encapsulated in TestSuite.hpp, this container holds multiple TestGroups. It orchestrates the overall test execution by aggregating groups and running them collectively.
• Optional/Additional Elements: In the code, there’s evidence of an optional test case flag (param_option), which is related to how test failures are treated.
Relationships and Flow
• A TestSuite is at the highest level, holding references to one or more TestGroups (each represented by AssertionGroup).
• Each TestGroup (AssertionGroup) contains and manages multiple TestCases.
• The flow starts from the TestSuite initiating the test run, which in turn triggers each TestGroup to execute all its contained TestCases.
Architectural Patterns and Design Principles
• Modular design: Each test component is separated into distinct header files, adhering to the single-responsibility principle.
• Composition: The framework is built hierarchically, composing lower-level components (TestCase) into higher-level ones (TestGroup and TestSuite).
• Extensibility: The design allows new test cases and groups to be added with ease, making it simple to extend functionalities.
• Lightweight design: The minimal file structure and clear separation of components ensure that the framework remains efficient and easy to understand.