This directory contains all test files and configurations for the Option Pricer project. The tests ensure that the library remains robust and free of regressions as new features are added or existing functionality is updated.
- Unit tests: Validate the behavior of individual components and modules.
- Integration tests: Ensure that modules work together as expected.
Please note that the basic structure for the tests has been implemented. Contributors are encouraged to add specific tests for new modules or enhance the existing tests to ensure full coverage.
tests
├── CMakeLists.txt
├── README.md
├── integration
│ ├── CMakeLists.txt
│ └── test_integration_option.cpp
├── test_main.cpp
└── unit
├── CMakeLists.txt
├── market_data
│ ├── test_market_data.cpp
│ └── test_stock_data.cpp
├── option
│ ├── test_base_option.cpp
│ ├── test_european_option.cpp
│ └── test_factory_european_option.cpp
├── payoff
│ ├── double_strikes
│ │ └── test_payoff_double_digital.cpp
│ └── single_strike
│ ├── test_payoff_digital.cpp
│ ├── test_payoff_vanilla.cpp
│ └── test_support
│ ├── common_payoff_single_strike_tests.h
│ └── fixture_payoff_single_strike.h
└── test_support
└── mock_classes.h
Make sure you have CMake and GTest installed. You can install GTest using a package manager or through vcpkg.
- Navigate to the project root directory:
cd path/to/your/project
- Create a build directory:
mkdir build && cd build
- Configure the project with CMake:
cmake ..
- Build the project:
cmake --build .
For automated testing or integration, you can run the all the tests executable using CTest:
ctest --output-on-failure
Alternatively, you can run specific tests:
- Run only Unit Tests:
ctest -R UnitTests --output-on-failure
- Run only Integration Tests:
ctest -R IntegrationTests --output-on-failure
You can also run all the tests at once by using the custom target Tests. For that purpose, you can build and run the Tests target as follows:
- Build the custom Tests target:
cmake --build . --target Tests
- Run the custom Tests target:
ctest -R Tests --output-on-failure
For detailed output, running the test using GTest can be a good approach for local development and debugging.
- Go to the build directory:
cd build
- Run the unit tests executable:
./tests/unit/Unit_tests
- Run the integration tests executable:
./tests/integration/Integration_tests
Add your new test file in the appropriate directory:
- For unit tests: Add the file to the
unit
directory. - For integration tests: Add the file to the
integration
directory.
Make sure to include the new test file in the respective CMakeLists.txt
:
- For unit tests, add the new test file in the
add_executable
andtarget_link_libraries
sections of theunit/CMakeLists.txt
:add_executable(Unit_tests ${CMAKE_CURRENT_SOURCE_DIR}/../test_main.cpp # Other test files... option/test_new_option.cpp) target_link_libraries(Unit_tests marketdata payoff option GTest::GTest GTest::Main GTest::gmock_main)
Use GTest and Google Mock to write your test cases. Refer to the GTest documentation for more details.
For any questions or contributions, please contact Anthony Makarewicz at [[email protected]].