jasmcaus / tau

A Micro (1k lines of code) Unit Test Framework for C/C++
MIT License
158 stars 30 forks source link

Add IGNORE_TEST and IGNORE_TEST_F macros #47

Closed stefano-p closed 1 day ago

stefano-p commented 2 days ago

Add IGNORE_TEST and IGNORE_TEST_F macros ๐Ÿš€

This feature allows developers to temporarily disable specific tests without removing them from the codebase. This is particularly useful when:

New Macros โœจ

Two new macros have been added:

Usage Example ๐Ÿ’ก

#include <tau/tau.h>

// Regular test case that will be executed
TEST(MathSuite, Addition) {
    int result = 2 + 2;
    CHECK_EQ(result, 4);
}

// This test will be ignored but remains in the codebase
IGNORE_TEST(MathSuite, ComplexCalculation) {
    int result = perform_complex_calculation();
    CHECK_EQ(result, 42);
}

// Setup for fixture
TEST_F_SETUP(DatabaseFixture) {
    tau->db = database_connect();
}

// Teardown for fixture
TEST_F_TEARDOWN(DatabaseFixture) {
    database_disconnect(tau->db);
}

// This fixture test will be ignored but setup/teardown are preserved
IGNORE_TEST_F(DatabaseFixture, SlowQuery) {
    bool query_result = database_execute_heavy_query(tau->db);
    CHECK_TRUE(query_result);
}

// This fixture test will run normally
TEST_F(DatabaseFixture, QuickQuery) {
    bool query_result = database_execute_simple_query(tau->db);
    CHECK_TRUE(query_result);
}

TAU_MAIN()

Output Example ๐Ÿ–ฅ๏ธ

[==========] Running 4 test suites.
[ RUN      ] MathSuite.Addition
[       OK ] MathSuite.Addition (0.001s)
[ IGNORED  ] MathSuite.ComplexCalculation
[ RUN      ] DatabaseFixture.QuickQuery
[       OK ] DatabaseFixture.QuickQuery (0.003s)
[ IGNORED  ] DatabaseFixture.SlowQuery
[==========] 2 test suites ran
[  PASSED  ] 2 suites

Summary:
    Total test suites:          4
    Total suites run:           2
    Total warnings generated:   0
    Total suites skipped:       2
    Total suites failed:        0

Implementation Details ๐Ÿ”ง

Backwards Compatibility โšก

This change is fully backwards compatible:

Testing ๐Ÿงช

The implementation has been tested with: