Unit Testing in matrix.py

Does anyone know what happened to the Unit Testing in matrix.py?

1 Like

I remember wondering about that, and I think I remember someone (@goodmami ?.. ) saying that they did not end up being used… Perhaps an unfinished project? All I can say with certainty is, in my work on the Matrix between 2015 and 2021, I never used them in any form.

1 Like

Regression tests used to be called unit tests in the Matrix. I advocated changing the name and at the same time I tried to start writing some proper unit tests (i.e., testing that the output of individual functions was correct), but didn’t get very far, partly because the Matrix functions were very interdependent and hard to write tests for, and partly because it was a lot of thankless work to write them.

The linked wiki page is outdated. Hardly anyone uses the unittest module anymore as the 3rd party pytest module is the de facto standard. There’s nothing wrong with making mock objects. It’s fine to have more than one test function for a code function (preferred, even). Using “outside” files is fine, as long as it’s stored and loaded correctly. And so on.

I think the last time I checked (years back), the Matrix unit tests no longer passed as the code had moved on without the tests being updated. If they can be made to work (or removed), it could be good to write tests for newly added/updated functionality. Well-written tests should make it easier to debug things and ensure correctness, but it is a bit of work to write and maintain them.

2 Likes