apjanke/octave-testify

Refactor the code

apjanke opened this issue · 2 comments

The test function's code has some issues:

  • The main function is several hundred lines long.
  • Logic for parsing tests, running tests, and tracking results is interleaved across the whole function.
  • All variables are prefixed with "__", hurting readability.
  • It uses local functions, which can't be called directly, so they're hard to test.
  • Results tracking is handled by seven or eight separate local variables.
  • It uses eval logic with generated temporary function strings, which is a little hard to follow.

Same goes for runtests, to a lesser extent.

Refactor the code to address this.

TODO

  • Factor out test-running implementation to objects
  • Test results summary in runtests2
  • Give runtests2 log file handling (for the lower-level test output)
  • More sophisticated input parsing for runtests2, for multiple targets, logging options, etc.
  • Have __run_test_suite__ use runtest2's summary output

I'm deferring logging to a separate issue #56 because it's a more complicated topic and doesn't block the refactoring itself.

I'm happy with the refactoring now. Moved test2_refactor and runtests2_refactor back to test2 and runtests2 in 91d8fe7.