Core functionality that must be tested:
- Strain analysis algorithms (point normalization, tensor calculations)
- Data processing (regression analysis, data transformations)
- Data export/import operations
UI and visual elements that we intentionally skip:
- Main Streamlit app flow
- Basic UI layout and styling
- Visual elements (manual testing preferred)
Tests core strain analysis algorithms in strain_analysis_core.py
:
- Point normalization and scaling: Ensures accurate spatial measurements
- Strain tensor calculations: Validates deformation analysis
- Edge cases: Handles invalid inputs and boundary conditions
Tests data processing and visualization in strain_analysis_data.py
:
- Scientific formatting: Ensures consistent number representation
- Regression analysis: Validates strain trend calculations
- Data export: Verifies correct data serialization
- Plot creation: Confirms visualization data integrity
pytest # Run all tests
pytest --cov # Run with coverage
- Test Independence: Each test should be independent and not rely on other tests
- Clear Test Names: Use descriptive names that explain the expected behavior
- DRY Principle: Use fixtures and helper functions to avoid code duplication
- KISS Principle: Keep tests simple and focused on one aspect
- Meaningful Assertions: Test behavior, not implementation details
- Edge Cases: Include tests for boundary conditions and error cases
When adding new tests:
- Follow the existing test structure
- Use appropriate fixtures for common test data
- Include both positive and negative test cases
- Document any special considerations or assumptions
- Ensure tests are maintainable and readable