Skip to content

test: expand coverage to 100% and add 90% coverage gate to CI - #32

Merged
lordlabakdas merged 4 commits into
mainfrom
tests
Jun 6, 2026
Merged

lordlabakdas merged 4 commits into
mainfrom
tests

Conversation

@lordlabakdas

Copy link
Copy Markdown
Owner

Summary

  • Expanded test coverage from 62% → 100% (47 tests, up from 20)
  • Added --cov-fail-under=90 to the CI workflow so coverage regressions block the build
  • Added pytest-cov to requirements.txt

New test files

File Tests Coverage target
tests/test_exe_comm.py 3 subprocess capture/no-capture paths, encoding
tests/test_trace.py 10 _unit_factor, _bottleneck_speed, a2b/b2a parsing, no-connections exit, bad timestamp fallback
tests/test_processor.py 3 PcapProcessor.__init__, process(), process_and_write() delegation
tests/test_runner.py 5 SimulationRunner shape/cleanup/missing-ascii, BfsRunner xscale loop and per-flow writes
tests/test_dce_runner.py 4 with/without scenario routing, custom jobs_dir, init
tests/test_simulation.py +2 else branch in QueueSizeCalculator, bottleneckSpeed in WafCommandBuilder

Test plan

  • pytest --cov=pcapprocessor --cov-fail-under=90 passes locally (100% coverage, 47/47 tests)
  • All subprocess/binary calls mocked — no external tools required in CI
  • CI workflow updated to enforce coverage gate on every push/PR

🤖 Generated with Claude Code

lordlabakdas and others added 4 commits June 5, 2026 21:04
Expand test coverage from 62% to 100% by adding tests for all
previously untested modules (exe_comm, trace, runner, processor,
dce_runner) using mocks for subprocess and external binaries.
Add missing branch tests for simulation.py. Add pytest-cov to
requirements.txt and wire --cov-fail-under=90 into the CI workflow
so coverage regressions block the build.

Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
sys.exit() in library code is a code smell — callers can't catch it
meaningfully. Raise ValueError instead so the error propagates
cleanly. Update the test to match.

Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
Move CLI logic into _main() which returns an int, so sys.exit()
only appears as the sole statement in __main__ — the standard
pattern that static analysers accept.

Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
@lordlabakdas
lordlabakdas merged commit abf3ce8 into main Jun 6, 2026
6 of 7 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant