Skip to content

Add comprehensive test coverage (91 → 444 tests)#4

Merged
sipemu merged 3 commits into
mainfrom
test/3-comprehensive-test-coverage
Feb 26, 2026
Merged

Add comprehensive test coverage (91 → 444 tests)#4
sipemu merged 3 commits into
mainfrom
test/3-comprehensive-test-coverage

Conversation

@sipemu
Copy link
Copy Markdown
Owner

@sipemu sipemu commented Feb 26, 2026

Summary

  • Add ~50 new test cases across 10 files, bringing total from 91 to 444 passing tests
  • Fix bare tibble() calls in test helpers to use tibble::tibble() for reliable namespace resolution under devtools::test()
  • Add create_mock_task_with_factors() and create_fitted_mock_task() test helpers

New test coverage by area:

Area Tests added Files
End-to-end pipeline per model 7 test_execute.R
BMPTest, PatellZTest, CalendarTimePortfolioTest 3 test_multi_event_statistics.R
plot_event_study, plot_diagnostics, plot_stocks 12 test_plotting.R (new)
Validation edge cases 4 test_validation.R
Diagnostics edge cases 3 test_diagnostics.R
Return calculation edge cases 5 test_return_calculation.R
Cross-sectional regression 5 test_cross_sectional.R
Export content validation 3 test_export.R
Tidy edge cases 3 test_export.R

Refs #3

Test plan

  • devtools::test() passes: 444 tests, 0 failures, 0 warnings

🤖 Generated with Claude Code

sm-DataZoo and others added 2 commits February 26, 2026 20:17
New tests added:
- End-to-end pipeline tests for all models (MarketAdjusted,
  ComparisonPeriodMeanAdjusted, BHAR, Volatility, FF3, FF5, Carhart)
- Functional tests for BMPTest, PatellZTest, CalendarTimePortfolioTest
- Plot function tests (plot_event_study, plot_diagnostics, plot_stocks)
- Validation edge cases (insufficient estimation obs, window overlap,
  thin trading, time series gaps)
- Diagnostics edge cases (pretrend_test filtering, value ranges)
- Return calculation edge cases (custom columns, log/simple agreement)
- Cross-sectional regression (ANOVA path, single group, car_window,
  non-matching event_ids)
- Export content validation (read back CSV, verify columns)
- Tidy edge cases (non-regression models, missing stat_name)

Also fixes bare tibble() calls in test helpers to use tibble::tibble()
for reliable namespace resolution under devtools::test().

Refs #3

Co-Authored-By: Claude Opus 4.6 <[email protected]>
Tests cover: single-event multi-event stats, NA propagation, zero-variance
returns, division-by-zero in forecast error correction, constant AARs,
zero/negative prices, single-day event windows, empty event windows,
BHARTTest NA coalesce, task accessor error paths, ParameterSet with null
stats, and validation edge cases. Full suite now at 504 tests.

Co-Authored-By: Claude Opus 4.6 <[email protected]>
@sipemu
Copy link
Copy Markdown
Owner Author

sipemu commented Feb 26, 2026

Added: 60 edge case tests

New file test_edge_cases.R covers degenerate data and boundary conditions:

  • Single-event multi-event stats: CSectTTest, SignTest, GeneralizedSignTest, RankTest, BMPTest with n=1
  • NA propagation: Multi-event stats with all-NA abnormal returns
  • Zero variance / constant returns: MarketModel, MarketAdjustedModel, ComparisonPeriodMeanAdjustedModel with constant data
  • Division by zero: Forecast error correction with sigma≈0, PatellZTest with very short estimation windows
  • Return calculation edge cases: Zero prices, negative prices (NaN), SimpleReturn zero-division
  • Single-day event window: Full pipeline with event_window_length=0
  • Empty event window: Event date not found in data
  • BHARTTest NA coalesce: Verifying NA→0 fallback behavior
  • Task accessor error paths: get_ar(), get_car() before fitting
  • ParameterSet null stats: Pipeline with all statistics set to NULL
  • Validation edge cases: Multiple event dates, unfitted model diagnostics
  • CalendarTimePortfolioTest: Constant AARs input

Also documents a known bug: MarketModel$calculate_statistics() crashes with zero-variance index returns (subscript out of bounds) because calculate_statistics() is not wrapped in safely().

Full test suite: 504 tests, 0 failures, 0 warnings.

Set up R-CMD-check on Ubuntu/macOS/Windows (R release + devel) and a
separate coverage job using covr + Codecov. Add R-CMD-check and Codecov
badges to README. Add covr to Suggests.

Co-Authored-By: Claude Opus 4.6 <[email protected]>
@sipemu sipemu merged commit fb5121e into main Feb 26, 2026
1 of 5 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.

2 participants