I don't think there are any rules that would apply to every situation.
Some general things, though:
- Tests should provide coverage of the code. This is more than just
lines covered (which is what the coverage tool will tell you). It
really means you should cover all the possible code paths.
- As one instance of this, you should try to test any corner cases.
Corner cases usually represent trivial input, so they generally are
very fast tests, but they are important because it's easy to code them
wrong.
- As for the speed of the tests, you should avoid tests that are
slower than necessary (like don't use a very large expression if a
small expression would test the same thing). However, I would worry
more about coverage than test speed. Don't be afraid to add a lot of
tests. That PR you referenced doesn't seem to have too many tests to
me.
- It's also a good idea to stress test every once in awhile. We don't
do this enough in SymPy IMHO. This means test that are larger than
usual. It could also mean tests that are only fast if the code is
properly tuned, to test against performance regressions.
- Tests often test more than one thing implicitly (e.g., a test may
test the output of a function, but also implicitly test that the
function does not raise an exception). However, it should be clear
from a test what it is explicitly testing.
Aaron Meurer
> --
> You received this message because you are subscribed to the Google Groups
> "sympy" group.
> To unsubscribe from this group and stop receiving emails from it, send an
> email to
sympy+un...@googlegroups.com.
> To post to this group, send email to
sy...@googlegroups.com.
> Visit this group at
http://groups.google.com/group/sympy.
> To view this discussion on the web visit
>
https://groups.google.com/d/msgid/sympy/a5ef6de8-1e83-4ea6-bdb6-ec351d9011b9%40googlegroups.com.
> For more options, visit
https://groups.google.com/d/optout.