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 File | What it Tests |
|---|---|
tests/System/ArrayTests.cpp | System::Array static helpers |
tests/System/BitConverterTests.cpp | System::BitConverter |
tests/System/Collections/Generic/CollectionsTests.cpp | List, Dictionary, HashSet |
tests/System/Collections/Generic/QueueStackTests.cpp | Queue, Stack |
tests/System/Collections/ImmutableCollectionTests.cpp | Immutable collections |
tests/System/DateTimeTests.cpp | System::DateTime |
tests/System/DecimalTests.cpp | System::Decimal |
tests/System/ConvertTests.cpp | System::Convert |
tests/System/StringTests.cpp | System::String utilities |
tests/CompressionTests.cpp | GZipStream, DeflateStream, ZipArchive |
tests/CalendarTests.cpp | Globalization calendars |
tests/System/Threading/ | Threading primitives |
| 74 total test files |
Test Coverage
| Category | Coverage |
|---|---|
| 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.