Overview: Fossil Test is a robust unit testing and mocking framework developed by Fossil Logic. It is designed to facilitate the creation of high-quality test cases across any C and C++ project. The framework supports Behavior-Driven Development (BDD), Domain Driven Development (DDD), and Test-Driven Development (TDD) styles, providing a flexible and comprehensive solution for ensuring software reliability and correctness.
In addition to Fossil Test, Fossil Logic also offers two additional frameworks: Fossil Mark and Fossil Mock. Fossil Mark is a powerful benchmarking framework that allows developers to measure the performance of their code and identify areas for optimization. With built-in timing information and detailed reporting, developers can easily track the execution time of each test case and make informed decisions to improve the efficiency of their software.
Fossil Mock, on the other hand, provides powerful mocking capabilities that enable developers to simulate the behavior of complex dependencies. This ensures focused and reliable unit tests, as developers can create mock objects that mimic the behavior of real dependencies, allowing for thorough testing of different scenarios.
By combining the features of Fossil Test, Fossil Mark, and Fossil Mock, developers can create robust and performant code, ensuring the quality and reliability of their software projects.
Key Features:
Feature | Description |
---|---|
BDD and TDD Support | Allows developers to write tests in both BDD and TDD styles, catering to various development and testing preferences. |
Unit Testing | Provides a complete suite of tools for writing and executing unit tests, ensuring that individual units of code perform as expected. |
Mocking Capabilities | Includes powerful mocking features that enable developers to simulate the behavior of complex dependencies, ensuring focused and reliable unit tests. |
Test Case Management | Supports organizing and managing test cases efficiently, with features for categorizing, prioritizing, and tagging tests. |
Detailed Reporting | Generates detailed reports on test execution, including information on passed, failed, skipped, and timed-out tests, helping developers quickly address issues. |
Performance Tracking | Tracks the performance of each test case with built-in timing information, allowing developers to monitor and optimize test execution time. |
Assertion Detection | Detects whether assertions are used within the code, ensuring that critical conditions are enforced and identifying areas that may lack proper validation. |
Command-Line Interface (CLI) | Includes a powerful CLI for running tests, generating reports, and managing the test suite from the command line, enhancing automation and integration. |
Extensible and Configurable | Designed to be extensible and configurable, allowing developers to tailor the framework to their specific needs, from reporting formats to tool integration. |
Before getting started, make sure you have the following installed:
- Meson Build System: This project relies on Meson. If you don't have Meson installed, visit the official Meson website for installation instructions.
-
Install Meson Build System: Before integrating the dependency, ensure you have Meson
1.3
or newer installed on your host system. You can install it with this command.python -m pip install meson # to install Meson python -m pip install --upgrade meson # to upgrade Meson
-
Adding Wrap File: You can add a
.wrap
file by first navigating to thesubprojects
directory and creatingfossil-test.wrap
. Next, copy the definition into the file:# ====================== # Git Wrap package definition # ====================== [wrap-git] url = https://github.com/fossillogic/fossil-test.git revision = v1.0.5 [provide] fossil-test = fossil_test_dep fossil-mock = fossil_mock_dep fossil-mark = fossil_mark_dep
-
Integrate the New Dependency: After creating the dependency
.wrap
file, you need to integrate it into your Meson project. This typically involves adding the dependency to yourmeson.build
file. Here's an example of how you might do that:dep = dependency('fossil-test')
This line retrieves the
fossil-test
dependency, allowing you to use it in your project. Releases Page: Head over to the Fossil Test Releases to find any preferred version of the framework. For the best experience with Fossil Test, it is recommended to always use the latest release.
The Fossil Test CLI is a command-line tool designed to help you run and manage your test suite efficiently. Below are the available commands and options:
Command | Description |
---|---|
--version |
Displays the version of the Fossil Test CLI. |
--help |
Shows the help message with usage instructions. |
--tip |
Provides a tip or hint about using the Fossil Test CLI. |
--info |
Displays information about the test runner. |
--author |
Shows information about the author of the test runner. |
only=<tag> or only=<tags> |
Runs only the tests tagged with the specified tag(s). Tags should be comma-separated for multiple tags. |
reverse [enable/disable] |
Enables or disables the reverse order of test execution. |
repeat=<number> |
Repeats the test suite for the specified number of times. |
shuffle [enable/disable] |
Enables or disables the shuffling of test execution order. |
verbose [cutback/normal/verbose] |
Sets the verbosity level of the output. Options are cutback , normal , and verbose . |
list |
Lists all available tests. |
summary [enable/disable] |
Enables or disables the summary of test results after execution. |
color [enable/disable] |
Enables or disables colored output in the terminal. |
sanity [enable/disable] |
Enables or disables sanity checks before running the tests. |
-
Display version information:
fossil_cli --version
-
Show help message:
fossil_cli --help
-
Run only tests tagged with "unit" and "integration":
fossil_cli only=unit,integration
-
Enable reverse order of test execution:
fossil_cli reverse enable
-
Repeat the test suite 5 times:
fossil_cli repeat=5
-
Enable verbose output:
fossil_cli verbose verbose
-
List all available tests:
fossil_cli list
-
Enable test result summary:
fossil_cli summary enable
-
Enable colored output:
fossil_cli color enable
Feel free to explore and use the various commands and options to tailor the test runner to your needs. For further assistance, refer to the --help
command.
You have options when configuring the build, each serving a different purpose:
- Running Tests: To enable running tests, use
-Dwith_test=enabled
when configuring the build.
Example:
meson setup builddir -Dwith_test=enabled
If you're interested in contributing to this project, encounter any issues, have questions, or would like to provide feedback, don't hesitate to open an issue or visit the Fossil Logic Docs for more information.
Fossil Test is a comprehensive solution for C and C++ developers aiming to ensure the quality and reliability of their code. By supporting both BDD and TDD, along with powerful mocking, assertion detection, detailed reporting, and a robust CLI, Fossil Test empowers developers to create robust and maintainable test suites. Its flexibility and extensibility make it a valuable tool for projects of any size and complexity, fostering a culture of quality and continuous improvement.