https://github.com/dunningkrueg/automated-testing-framework-unit-test-
https://github.com/dunningkrueg/automated-testing-framework-unit-test-
Last synced: 3 months ago
JSON representation
- Host: GitHub
- URL: https://github.com/dunningkrueg/automated-testing-framework-unit-test-
- Owner: dunningkrueg
- Created: 2025-01-26T08:49:05.000Z (4 months ago)
- Default Branch: main
- Last Pushed: 2025-01-26T08:50:03.000Z (4 months ago)
- Last Synced: 2025-02-08T09:20:20.648Z (4 months ago)
- Language: C
- Size: 1.95 KB
- Stars: 1
- Watchers: 1
- Forks: 0
- Open Issues: 0
-
Metadata Files:
- Readme: README.md
Awesome Lists containing this project
README
# C Unit Testing Framework
easy-to-use unit testing framework for C projects.
## Features
- Zero external dependencies
- Minimal setup required
- Colored test output
- Automatic execution time measurement
- Memory leak detection
- Cross-platform compatibility
- Thread-safe implementation## Quick Start
1. Add the framework to your project:
```bash
copy test_framework.h your/project/directory
```2. Create your test file:
```c
#include "test_framework.h"void test_function() {
ASSERT_EQ(4, 2 + 2);
}int main() {
TEST_SUITE_BEGIN();
RUN_TEST(test_function);
TEST_SUITE_END();
return 0;
}
```3. Compile and run:
```bash
gcc -o test_runner your_test_file.c
./test_runner
```## Available Assertions
- `ASSERT_EQ(expected, actual)`: Compare two values for equality
- `ASSERT_STR_EQ(expected, actual)`: Compare two strings for equality
- `ASSERT_TRUE(condition)`: Verify if condition is true## Requirements
- C compiler (GCC, Clang, or MSVC)
- Standard C library## Project Structure
```
├── test_framework.h # Main framework header
├── example.c # Example usage
├── .gitignore # Git ignore rules
└── README.md # This file
```## Build Instructions
### Windows (MinGW)
```bash
gcc -o test_runner example.c -Wall -Wextra -pedantic
```### Linux/MacOS
```bash
gcc -o test_runner example.c -Wall -Wextra -pedantic
```## Best Practices
1. Create separate test files for each module
2. Name test functions descriptively
3. Test both valid and edge cases
4. Free allocated memory in string tests
5. Keep tests focused and independent