Skip to content

Testing

AT! edited this page Jun 17, 2025 · 6 revisions

Continuous Integration

GitHub Actions

This repository is automatically tested at each release by GitHub Actions. The automatic tests will ensure that the code compiles correctly, and the production of different outputs from a test file.

Manual testing

Enhanced Test Suite (v1.4.0+)

As of version 1.4.0, covtobed includes a comprehensive testing framework:

# Run all tests (unit, integration, benchmarks)
cd test
bash run_tests.sh --all

# Run specific test types
bash run_tests.sh --unit        # Unit tests with Catch2
bash run_tests.sh --integration # Enhanced integration tests
bash run_tests.sh --benchmark   # Performance benchmarks

The enhanced testing suite includes:

  • Unit tests: Using Catch2 framework for core classes
  • Integration tests: Comprehensive functional testing with colored output
  • Benchmarks: Performance testing with Google Benchmark
  • Test data generation: Synthetic BAM/SAM file creation

Legacy Test Script

The original test script ./test/test.sh is still available and assumes:

  • To be invoked from the root of the repository (this is not required, but it's the way GitHub Actions will invoke it)
  • That a binary called covtobed is placed at the root of the repository. Should the binary not be at the root, the test script will attempt copying a pre-compiled binary from the ./binaries directory.

What is tested

Some example BAM files are present in the test directory:

  • demo.bam is a simulated single-end whole-genome shotgun of Enterobacteria phage lambda
  • mp.bam is a simulated mate pairs library of Enterobacteria phage lambda
  • mock.bam is a synthetic version of demo.bam that will produce 3 peaks of coverage (20X, 5X, 5X respectively)
  • filtered.bam is a synthetic BAM file containing a valid alignment and non valid flags (PCR duplicate, non primary, failed QC)
  • test_cov.bam is a synthetic BAM file having a peak per chromosome, and each chromosome is named after the coverage of its peak (e.g. "5X" means expecting a peak of 5X coverage)

What is tested:

  1. The binary compiled and can be invoked printing its version
  2. A sample test/demo.bam is analyzed using "--min-cov 15", and should produce 12 lines of BED
  3. A sample test/mp.bam is analyzed using "--physical-coverage", and should produce 136 lines
  4. A sample test/demo.bam is analyzed using "--output-strands", and should produce a fifth column
  5. A sample test/demo.bam is analyzed using "--format counts", and should print two header lines and 202 non-header lines
  6. A sample test/demo.bam is analyzed and should re-produce the reference test/demo.bed of the repository
  7. A sample test/mock.bam is analyzed and should re-produce the reference test/demo.bed of the repository
  8. A sample test/test_cov.bam is analyzed and the output is checked for having a peak per chromosome, and each chromosome is named after the coverage of its peak

Example output: all tests pass

covtobed 1.4.0
Copyright (C) 2014-2019 Giovanni Birolo and Andrea Telatin
https://github.com/telatin/covtobed - License MIT.
This is free software: you are free to change and redistribute it.
There is NO WARRANTY, to the extent permitted by law.
 - Compiled binary prints version: PASS 1
 - Minimum coverage, expected BED lines check: PASS 2
 - Physical coverage, expected BED lines check: PASS 3
 - Stranded output, testing column #5: PASS 4
 - Testing 'counts' format (printed headers): PASS 5
 - Testing 'counts' format (printed lines): PASS 6
 - Checking identity of BED output with pre-calculated: PASS 7
 - Checking computed coverage for a synthetic BAM file: PASS 8
 - Checking filtering of invalid alignments: PASS 9,10
 - Checking artificial coverage values:
	#OK expecting 1X, 1X found
	#OK expecting 2X, 2X found
	#OK expecting 10X, 10X found
ALL TESTS: PASSED

Clone this wiki locally