I’m trying to figure out how to use the qcumber
unit-testing library.
I have src/ti.q
sma: {mavg[x; y]}; /simple moving average
and tests/sma.quke
feature sma
before
inputData: 1 2 3 4 5 6 7 8 9 10;
expectedOutput: 1 1.5 2 2.5 3 4 5 6 7 8;
period: 5;
should
expect
.qu.compare[expectedOutput; sma[period;inputData]]
I run the test via q $AXLIBRARIES_HOME/ws/qcumber.q_ -src ./src/ti.q -test ./tests -color -showAll
which gives
Starting qCumber: q test runner
q)Loading src file: src/ti.q
Running tests: tests
file ti.quke
feature sma
(should)
- fail | (expect)
error: inputData (line 7)
Summary:
0 tests passed
0 benchmarks failed
1 tests failed
0 tests skipped
Clearly there is an issue with my tests/sma.quke
file but I haven’t been able to figure out how to pass in constants from the documentation at Testing framework for q(.qu). How do I get my expect
block to see the variables defined in the before
block (If indeed block
is what’s required)?