libxlsxwriter
|
This section shows how to set up and run the test suite for libxlsxwriter.
The functional tests compare the output from libxlsxwriter against xlsx files created in Excel.
The functional tests use the Python module pytest as a test runner.
Install the pytest
module using one of the following methods:
sudo apt-get install -y python-pytest # or sudo pip install pytest
The functional tests can then be run:
$ cd libxlsxwriter $ make test_functional =========================== test session starts =========================== collected 749 items test/functional/test_array_formula.py::TestCompareXLSXFiles::test_array_formula01 PASSED [ 0%] test/functional/test_array_formula.py::TestCompareXLSXFiles::test_array_formula02 PASSED [ 0%] test/functional/test_array_formula.py::TestCompareXLSXFiles::test_array_formula03 PASSED [ 0%] test/functional/test_array_formula.py::TestCompareXLSXFiles::test_array_formula04 PASSED [ 1%] test/functional/test_autofilter.py::TestCompareXLSXFiles::test_autofilter00 PASSED [ 1%] test/functional/test_autofilter.py::TestCompareXLSXFiles::test_autofilter01 PASSED [ 1%] ... test/functional/test_write_data.py::TestCompareXLSXFiles::test_data05 PASSED [ 99%] test/functional/test_write_data.py::TestCompareXLSXFiles::test_data06 PASSED [ 99%] test/functional/test_write_data.py::TestCompareXLSXFiles::test_data07 PASSED [ 99%] test/functional/test_write_data.py::TestCompareXLSXFiles::test_data08 PASSED [ 99%] test/functional/test_write_data.py::TestCompareXLSXFiles::test_data09 PASSED [100%] =========================== 749 passed in 30.60s ===============================
The unit tests test the components of the library at the level of individual functions or compilation units.
The unit tests uses the ctest test framework. This is included as a header file in the test/unit
directory and doesn't need to be installed.
The unit tests can then be run as follows:
$ make test_unit Compiling unit tests ... TEST 1/429 utility:lxw_col_to_name [OK] TEST 2/429 utility:test_datetime_date_and_time [OK] TEST 3/429 utility:test_datetime_date_only [OK] TEST 4/429 utility:test_datetime_date_only_1904 [OK] TEST 5/429 utility:test_datetime_time_only [OK] TEST 6/429 utility:test_unixtime [OK] ... TEST 425/429 worksheet:worksheet_table12 [OK] TEST 426/429 worksheet:worksheet_table13 [OK] TEST 427/429 worksheet:worksheet_table14 [OK] TEST 428/429 worksheet:worksheet_table15 [OK] TEST 429/429 table:xml_declaration [OK] RESULTS: 429 tests (429 ok, 0 failed, 0 skipped) ran in 153 ms
Both functional and unit test can be run together:
$ make test
You can run the unit and functional tests via CMake as follows:
cd cmake cmake .. -DBUILD_TESTS=ON cmake --build . ctest -V
The functional tests and examples can be run under Valgrind to verify that there are no memory leaks.
Install valgrind
as follows:
apt-get install -y valgrind
Then run the tests:
make test_valgrind
For Static Analyis Libxlsxwriter uses:
Libxlsxwriter is configured to run all these tests with GitHub Actions Continuous Integration for each commit.