I am writing a unit-test framework (for Matlab/Octave, but that does not matter) which also supports property based testing. Thus, I need some functions which generate random data which are tailored for the functions under test (At the same time I am writing a scientific program which I test using my unit-test framework).
These data-generator functions are useful per se, not only in connection with unit tests. My question is, where shall I put the data-generator functions? I want that the framework can also be used for other projects (not just the one I am writing at the moment).
My current idea is, that the data-generators are not part of the unit-test framework. Intead, it belong to the software which is tested and I specify simple properties which the data-generators must have. The test framework then can use all data-generators which satisfy these properties.
- Is this approach good?
- What is "best practice" for this problem?
- What other approaches could I take.
E.g.
I have functions which transform a signal from time domain into frequency-domain (similar to FFT) and back. Thus, I want to test if my transform functions behave correctly, resp. how large the error is after transformation. For this to test I need a lot of signals of different types
- total positive functions
- bandlimited functions
- noise (coloured and white)
- functions whose Fourier Series diverges
- etc...
Another function I have computes spectral properties of sets of matrices For this to test I need a lot of various sets
- random matrices
- badly conditioned matrices
- sparse matrices
- matrices arising from some counterexamples
All of this examples are interesting per se for the user of the software I am writing. Thus, I want that the user has access to this data-generating functions.