Skip to content

Expand test coverage for SCORE2 algorithm #7

@fbraza

Description

@fbraza

Issue Description

Current test coverage for SCORE2 is limited to only 2 test cases, both for 50-year-old smokers.

Current Coverage

  • 50-year-old female smoker
  • 50-year-old male smoker

Missing Test Cases

1. Non-smokers

  • Male and female non-smokers at various ages

2. Different Age Ranges

  • Age <50 (different risk thresholds)
  • Age 50-69 (different risk thresholds)
  • Edge cases: age 40, 49, 50, 69

3. Edge Cases

  • Minimum biomarker values
  • Maximum biomarker values
  • Boundary values for risk categories

4. Error Conditions

  • Age outside 40-69 range
  • Invalid biomarker values
  • Missing required fields

Suggested Test Structure

@pytest.mark.parametrize(
    "filename,expected",
    [
        # Existing tests
        ("test__output__patient_25.json", (50.00, 4.34, "Low to moderate")),
        ("test__output__patient_26.json", (50.00, 6.31, "High")),
        
        # Non-smokers
        ("test__output__patient_nonsmoker_male.json", (55.00, 2.15, "Low to moderate")),
        ("test__output__patient_nonsmoker_female.json", (45.00, 1.82, "Low to moderate")),
        
        # Age ranges
        ("test__output__patient_age_40.json", (40.00, 1.95, "Low to moderate")),
        ("test__output__patient_age_69.json", (69.00, 12.34, "Very high")),
        
        # Edge cases
        ("test__output__patient_high_risk.json", (65.00, 15.67, "Very high")),
    ],
)
def test_score2(filename, expected):
    ...
    
def test_score2_age_validation():
    """Test that age validation works correctly."""
    with pytest.raises(ValueError, match="ages 40-69"):
        compute.cardiovascular_risk("test__invalid_age_30.json")

Impact

  • Ensures algorithm correctness across different scenarios
  • Validates edge case handling
  • Improves confidence in the implementation

Related

Metadata

Metadata

Assignees

Labels

enhancementNew feature or request

Projects

No projects

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions