mit-crpg / opendeplete

A depletion framework for OpenMC
MIT License
15 stars 5 forks source link

Add test suite #9

Closed cjosey closed 7 years ago

cjosey commented 7 years ago

This addition adds a mostly complete test suite for opendeplete. It includes unit tests for the more easily unit-testable portions of the code, integral tests for the integrator routines (using a simple, statistics-free test problem), and a full system test to ensure that all components work in concert.

This is the first time I've written tests for a big code like this, so comments strongly encouraged.

Test suite can be run by executing in the opendeplete directory. It took roughly 25 seconds on my computer.

python3 -m unittest

To get only the short tests, skipping over the full system test, run

python3 -m unittest test.test_depletion_chain test.test_integrator_coeffs test.test_integrator test.test_nuclide test.test_reaction_rates test.test_integrator_regression

These shorter tests will take roughly 0.3 seconds.

I would like to find a way to make different test suites without using a fully custom implementation like OpenMC does. I am yet unsure how to do that.

Currently missing tests are for function.py, openmc_wrapper.py, and utilities.py. The first two are due to the fact that, during testing, I realized I needed to rewrite these. Utilities is mostly due to not wanting to hardcode several results objects to test it out.

paulromano commented 7 years ago

Have you looked at using unittest.TestSuite for creating different test suites?

cjosey commented 7 years ago

I have addressed most of the issues, as well as added a test runner (test.py in the root directory). It allows for different test suites. I would use nose, but nobody supports nose anymore and they're recommending new projects not use it. nose2, its "successor" isn't available in a lot of default repositories.