Running Tests

GoogleTest framework, test structure, and how to run specific test suites.

Test Framework

sharp-runtime uses GoogleTest as its test framework. The test runner executable is SharpRuntimeTests, built automatically when SHARP_RUNTIME_BUILD_TESTS=ON (the default).

GoogleTest is provided as a git submodule at vendor/googletest/.

Running All Tests

./build/SharpRuntimeTests

Expected output:

[==========] Running 3132 tests from 471 test suites.
[----------] Global test environment set-up.
...
[  PASSED  ] 3132 tests.
[  FAILED  ] 0 tests.

Running a Specific Test Suite

# Run all tests whose name contains "String"
./build/SharpRuntimeTests --gtest_filter="String*"

# Run TcpClient tests only
./build/SharpRuntimeTests --gtest_filter="TcpClient*"

# Run a specific test
./build/SharpRuntimeTests --gtest_filter="ListTests.AddAndCount"

Running via CTest

cd build
ctest --output-on-failure

Test File Locations

Test files are in the tests/ directory, organized to mirror the include/System/ structure:

tests/

Test FileWhat it Tests
tests/System/ArrayTests.cppSystem::Array static helpers
tests/System/BitConverterTests.cppSystem::BitConverter
tests/System/Collections/Generic/CollectionsTests.cppList, Dictionary, HashSet
tests/System/Collections/Generic/QueueStackTests.cppQueue, Stack
tests/System/Collections/ImmutableCollectionTests.cppImmutable collections
tests/System/DateTimeTests.cppSystem::DateTime
tests/System/DecimalTests.cppSystem::Decimal
tests/System/ConvertTests.cppSystem::Convert
tests/System/StringTests.cppSystem::String utilities
tests/CompressionTests.cppGZipStream, DeflateStream, ZipArchive
tests/CalendarTests.cppGlobalization calendars
tests/System/Threading/Threading primitives
74 total test files

Test Coverage

CategoryCoverage
Total tested headers~408 / 449 (~91%)
Intentionally skipped (pure interfaces IXxx)~42
Types with real logic but no tests~0

Adding New Tests

Create a new .cpp file anywhere under tests/. CMake uses GLOB_RECURSE to find all test files automatically — no manual registration is needed.

// tests/System/MyNewTests.cpp
#include <gtest/gtest.h>
#include "System/MyNewClass.hpp"

TEST(MyNewClassTests, BasicTest) {
    // ...
    EXPECT_EQ(expected, actual);
}
ℹ Project invariant
3080+ tests must pass before any commit. The rule is: ./build/SharpRuntimeTests must show no failures.