All Data Structures Files Functions Variables Typedefs Enumerations Enumerator Macros Pages
Running the Test Suite

Table of Contents

This section shows how to set up and run the test suite for libxlsxwriter.

Functional Tests

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 easy_install pytest
# or
sudo pip install pytest

The functional tests can then be run:

$ cd libxlsxwriter

$ make test_functional

=========================== test session starts ===========================
collected 14 items

test/functional/ TestCompareXLSXFiles.test_format01 PASSED
test/functional/ TestCompareXLSXFiles.test_format02 PASSED
test/functional/ TestCompareXLSXFiles.test_format06 PASSED
test/functional/ TestCompareXLSXFiles.test_data04 PASSED
test/functional/ TestCompareXLSXFiles.test_data05 PASSED
test/functional/ TestCompareXLSXFiles.test_data06 PASSED
test/functional/ TestCompareXLSXFiles.test_data07 PASSED
=========================== 14 passed in 0.41 seconds =====================

Unit Tests

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/155 utility:_datetime_date_and_time [OK]
TEST 2/155 utility:_datetime_date_only [OK]
TEST 3/155 utility:_datetime_date_only_1904 [OK]
TEST 4/155 utility:_datetime_time_only [OK]
TEST 152/155 styles:write_xf34 [OK]
TEST 153/155 styles:write_xf35 [OK]
TEST 154/155 styles:write_xf36 [OK]
TEST 155/155 styles:xml_declaration [OK]

RESULTS: 155 tests (155 ok, 0 failed, 0 skipped) ran in 42 ms

Both functional and unit test can be run together:

$ make test

Valgrind Tests

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

Travis Continuous Integration

Libxlsxwriter is configured to run all tests in Travis Continuous Integration for each commit.

Next: Frequently Asked Questions