Skip to content

Latest commit

 

History

History
84 lines (68 loc) · 2.69 KB

README.md

File metadata and controls

84 lines (68 loc) · 2.69 KB

Running tests

At least Clang 7.0 and Clant-tidy 7.0 is required to run the tests.

Before running the tests the CodeChecker package needs to be built!

# Build the package
make package
cmd
make test run all tests (unit and functional)
make test_unit unittests
make test_functional functional tests (SQLite and PostgreSQL)
make test_sqlite functional test (SQLite)
make test_psql functional tests (PostgreSQL)
make TEST="tests/functional/cmdline" run_test run only a specific test (SQLite)

Clean test workspace

make test_clean

Run tests with PostgreSQL

At least one of the database drivers needs to be available to use the PostgreSQL database backend.
psycopg2 is used by default if not found pg8000 is used.

Nosetest configuration

.noserc configuration file in the repository root is used to configure running the tests: Further configuration options can be found here Nosetest usage.

Virtual environment to run tests

Test running virtual environment is automatically created and sourced by the make test* commands. Create a python virtualenv for development:

make venv_dev

Create new unit test

Use the add_new_unit_test.py script to generate new test files.

add_new_unit_test.py module_name

Add new tests for the created tests/unit/test_module_name.py filee and run the unit tests:

make test_unit

Create new functional test

Use the add_new_func_test.py script to generate new test files.

add_new_func_test.py newfeature

From the repository root run the new test template (should pass):

make TEST="tests/functional/mynewfeature" run_test

Modify __init__.py

In each functional test mynewfeature/__init__.py is doing the functional test setup:

  • exporting test related data to the test directories
  • analyzing a test project (multiple times if needed)
  • start a server connected to a specific database (should be stopped in teardown)
  • prepare and cleanup the test workspace
  • ...

Add new functional testcase

The actual test cases go to mynewfeature/test_mynewfeature.py file. The setup part of these test read up the generated test configuration file by __init__.py. Test cases should only use test related configuration values ONLY from the configuration file generated by the __init__.py. The tests should ONLY modify the files in the workspace provided for them.
Test cases can:

  • rerun the analysis
  • connect to the server started by the __init__.py
  • run command line commands
  • modify configuration files
  • ...