Testing features
NickSeagull opened this issue · 3 comments
- test: Run tests
- test-watch: Run tests in watch mode, rerunning on file changes
test: Run tests
With this command we may also be able to support property-based tests.
Discoverability
We should be able to execute as a test any function that meets the following criteria:
- The function is public.
- The function name starts with
test_
(configurable). - If a public function named
beforeEach
is present it can be executed before each test is run.
type | prefix | arguments | semantics |
---|---|---|---|
concrete | test_ |
no | single execution with concrete values |
property | test_ |
yes | multiple executions with randomly generated concrete values (smaller values) |
fuzz | test_ |
yes | multiple executions with randomly generated concrete values (biased)* |
*Also configurable.
For the biased case, depending on the underlying testing library (QuickCheck, hedgehog, falsify), there may exist a command that overrides the scope and shrinking of generated values so the tests can run in 'fuzz' mode. For example:
test
: Run testsfuzz
: Run tests (biased)
This looks awesome!
One of the things that I was thinking to promote was the usage of doctests. Many times folks skip writing tests because it is an additional task to do, and an afterthought in some way.
My hypothesis is that if we teach folks to describe and document their functions, as well as giving an example, we start getting a bit of test coverage, which is better than nothing.
On top of that, now with GitHub Copilot, writing a good documentation, along with examples (doc tests) the implementation of any code becomes much easier.
They also support property based testing, which is cool
Yes! I have been using doctest even in F# in the past and I agree with your thoughts around it.