Testing
Testing is a critical part of the bice development process. All new features and bug fixes must be accompanied by appropriate tests.
Running Tests
We use pytest as our test runner.
Run all tests:
pytest
Run specific test files:
pytest tests/unit/test_equation.py
Run with coverage:
pytest --cov=src/bice
Test Structure
Tests are located in the tests/ directory and are split into two categories:
Unit Tests (
tests/unit/): Test individual classes and functions in isolation. These should be fast and have minimal dependencies.Integration Tests (
tests/integration/): Test how different components work together, often using real equations like the Swift-Hohenberg Equation.
Writing New Tests
Place unit tests in
tests/unit/following the naming conventiontest_<module_name>.py.Use clear, descriptive function names for your tests.
Include assertions that verify both expected success and failure cases (using
pytest.raisesfor exceptions).If your test requires random numbers, use
np.random.default_rng()for reproducibility if possible.