digitalmars.D - Re: Unit tests in D
- bearophile <bearophileHUGS lycos.com> May 07 2010
Michel Fortin: Sorry for the delay in my answer, Michel.1. to print a list of all the tests as they run 2. to print a list of the tests that fails
For an IDE to find such lists in an easy way it's useful the point 4, to have those names in the JSON.Here's a way to do it with the current syntax: unittest { scope (failure) writeln("Calculate pi using method X: FAIL");
I didn't know/remember about this, it's nice.Whether we want to output a line for every test, I'm not sure.
I like a list of all unittests in the JSON, but I don't need an output line for every test. But I don't need dmd to print this, it can be left to the IDE.On the other hand, it's useful, especially when a test hangs, takes too long, or crashes the program, to be able to see the list of all the tests as they run.<
Some unit tests systems use a short output syntax, dmd can print the same: ....x.....x... Done 14 unit tests in 1.25 seconds, 2 failed.unittest "Calculate pi using method x" {
I prefer this syntax (from my original post I have removed the useles parenthesys around the unittest name): /// Calculate pi using method x unittest pi_with_x { ... }I'd suggest that the runtime print the name of a test when it fails:
This was point 3 in my original list. Using the suggestions by Lutger ('' symbols added): test.d(6): unittest 'pi_with_x' failed.If the environment variable D_VERBOSE_UNITTEST
I prefer normal compiler switches. Now I have received enough answers and I can write a bug report or DEP. The good thing is that all this doesn't require hard or big changes to dmd, just small changes. Bye and thank you, bearophile
May 07 2010