scientific-python/spin

Improve unit testing using frameworks

ganesh-k13 opened this issue · 2 comments

Problem today

test.sh is growing today and will not be particularly clean when more commands are added.

Proposal

Use any testing framework to make it easier to add more cases. I could think of two ways:

  1. We stick with bash and use https://github.com/bats-core/bats-core
  2. Migrate to pytest and use subprocess to call the spin commands

While the first method would probably be less code in the long term, it might not be as powerful as pytest. Parametrizing for instance would be easier.

I'd be happy to raise a PR to move to either or feel free to close this issue if we are ok to keep what we have for now.

ToDo

  • Add a pytest based testing framework
  • Add tests for
    • --version
    • build
    • test
    • PYTHONPATH based tests
    • docs
    • gdb
    • Other misc tests in test.sh
  • Depcrecate test.sh

The pytest route sounds good to me. I looked at the bash test frameworks before, and they're all somewhat sub-optimal.

We'll need to write some utility functions to check the outputs and error codes of commands, but that should be straightforward.

Thanks @ganesh-k13!

pytest might be a good choice. The ability to use parametrization can make it easier to add more test cases in the future. Bash has limited features compared to more pytest.