Safeheron-SGX-Native-Development-Framework v1.2.0
Loading...
Searching...
No Matches
ssgx::testframework_t::TestManager Class Reference

Manages registration and execution of test cases grouped into suites. More...

#include <ssgx_testframework_t.h>

Public Types

using TestFunc = std::function<void()>
 

Static Public Member Functions

static void AddTest (const char *suiteName, const char *testName, TestFunc func)
 Registers a test case with the framework.
 
static void RunSuite (const char *suiteName)
 Executes all registered test cases within a specific test suite.
 
static int RunAllSuites ()
 Executes all registered test suites and their test cases.
 

Detailed Description

Manages registration and execution of test cases grouped into suites.

This class provides a simple, static test framework infrastructure. It allows users to define test functions and register them under specific test case names within named test suites. It offers functionalities to run all tests within a specific suite or to run all registered suites sequentially.

Member Typedef Documentation

◆ TestFunc

using ssgx::testframework_t::TestManager::TestFunc = std::function<void()>

Member Function Documentation

◆ AddTest()

static void ssgx::testframework_t::TestManager::AddTest ( const char * suiteName,
const char * testName,
TestFunc func )
inlinestatic

Registers a test case with the framework.

Associates a test function (func) with a specific test name (testName) within a named test suite (suiteName). If the suite does not exist, it is created. If the suite already exists, the test case is added to it. This function should be called during test setup or initialization phase.

Parameters
[in]suiteNameThe name of the test suite to which this test belongs.
[in]testNameThe specific name identifying this test case within the suite.
[in]funcThe function object (lambda, function pointer, std::function) containing the test logic.
Note
Tests are stored internally and executed later via RunSuite() or RunAllSuites().

◆ RunAllSuites()

static int ssgx::testframework_t::TestManager::RunAllSuites ( )
inlinestatic

Executes all registered test suites and their test cases.

Iterates through all test suites that have been registered via AddTest. For each suite, it runs all its test cases sequentially, printing individual PASS/FAIL results and timing information, followed by a summary for that suite. After all suites have been executed, a final summary showing the total number of passed and failed tests across all suites is printed.

Returns
Returns 0 if all test cases across all suites passed; returns -1 if one or more test cases failed.

◆ RunSuite()

static void ssgx::testframework_t::TestManager::RunSuite ( const char * suiteName)
inlinestatic

Executes all registered test cases within a specific test suite.

Looks up the specified suite name and runs each registered test case sequentially. It captures exceptions (std::exception and others) to determine test failure. Results, including PASS/FAIL status, test name, and execution time (in milliseconds), are printed to standard output. A summary for the suite (total passed/failed) is printed at the end.

Parameters
[in]suiteNameThe name of the test suite to execute.

The documentation for this class was generated from the following file: