digitalmars.D - Data-drive (aka table-driven) tests
- Russel Winder via Digitalmars-d (29/29) Dec 04 2015 Is anyone looking at enabling proper data-driven tests by example.
- Chris Wright (6/15) Dec 04 2015 Builtin unittest {} blocks are extremely convenient, but they're quite
- Atila Neves (5/6) Dec 07 2015 That's literally the next feature I want to add to unit-threaded.
Is anyone looking at enabling proper data-driven tests by example. Trivial example: Factorial implementations, you just want to write a few examples in a table and have the compiler test them all individually with all being tested even if some fail. In languages that have assertions with termination semantics this is impossible to do with loops. Languages like Go have a test framework with no assertions per se just tools for reporting an error: in Go table driven testing is trivially easy. In Python, at least using PyTest, there is the pytest.mark.parametrize decorator that writes separate functions for each data item given the test function template. This works very nicely with the Python approach of terminating assertions since on execution there is a test function per test case from the table. I am finding that although this can be done trivially in dynamic languages, in static languages it is less so. Scala can do it due to the language semantics and macros. Rust cannot do it yet, the macro system isn't up to it. What about D? Has anyone tinkered with this? As an ancillary question: has anyone got a property-testing framework in D. The original is from Haskell, QuickCheck. Ceylon and similar languages have a pale imitation, Rust has the real thing. --=20 Russel. =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D= =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D= =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D= =3D=3D Dr Russel Winder t: +44 20 7585 2200 voip: sip:russel.winder ekiga.n= et 41 Buckmaster Road m: +44 7770 465 077 xmpp: russel winder.org.uk London SW11 1EN, UK w: www.russel.org.uk skype: russel_winder
Dec 04 2015
On Fri, 04 Dec 2015 18:49:39 +0000, Russel Winder via Digitalmars-d wrote:Is anyone looking at enabling proper data-driven tests by example. I am finding that although this can be done trivially in dynamic languages, in static languages it is less so. Scala can do it due to the language semantics and macros. Rust cannot do it yet, the macro system isn't up to it. What about D? Has anyone tinkered with this?Builtin unittest {} blocks are extremely convenient, but they're quite low on features. If specd still works, that would probably be much more suited to this type of testing. http://code.dlang.org/packages/specdAs an ancillary question: has anyone got a property-testing framework in D. The original is from Haskell, QuickCheck. Ceylon and similar languages have a pale imitation, Rust has the real thing.http://code.dlang.org/packages/dcheck perhaps?
Dec 04 2015
On Friday, 4 December 2015 at 18:49:39 UTC, Russel Winder wrote:[...]That's literally the next feature I want to add to unit-threaded. Looping isn't good enough, I want to know which variant made it fail. Atila
Dec 07 2015