Thread overview | |||||
---|---|---|---|---|---|
|
July 25, 2016 Randomized unittests | ||||
---|---|---|---|---|
| ||||
Is there any leverage in the D library for doing randomized unit testing? Testing things with a range of possibilities instead of fixed. Each time the test is ran a different version is executed. This provides more coverage. How does one create a random number at compile time? Is this the only way: http://dpaste.dzfl.pl/668646ce6d71? |
July 25, 2016 Re: Randomized unittests | ||||
---|---|---|---|---|
| ||||
Posted in reply to Gorge Jingale | On Mon, 25 Jul 2016 01:49:25 +0000, Gorge Jingale wrote: > Is there any leverage in the D library for doing randomized unit > testing? Testing things with a range of possibilities instead of fixed. > Each time the test is ran a different version is executed. > This provides more coverage. > > How does one create a random number at compile time? Is this the only way: > > http://dpaste.dzfl.pl/668646ce6d71? http://code.dlang.org/packages/unit-threaded @Values() annotation on a unittest takes a range. Base that on a range that yields random values and Bob's your uncle. That range may need to be a compile-time constant. If so, it will be a little awkward to create, and you can ping Atila about possibly creating a @ValuesFrom annotation that will take a method or lambda that yields a range of values. |
July 25, 2016 Re: Randomized unittests | ||||
---|---|---|---|---|
| ||||
Posted in reply to Chris Wright | On Monday, 25 July 2016 at 02:36:04 UTC, Chris Wright wrote:
> On Mon, 25 Jul 2016 01:49:25 +0000, Gorge Jingale wrote:
>
>> [...]
>
> http://code.dlang.org/packages/unit-threaded
>
> @Values() annotation on a unittest takes a range. Base that on a range that yields random values and Bob's your uncle.
>
> That range may need to be a compile-time constant. If so, it will be a little awkward to create, and you can ping Atila about possibly creating a @ValuesFrom annotation that will take a method or lambda that yields a range of values.
Thanks, looks nice, a bit confusing but seems pretty useful.
But why is Bob my uncle? ;)
|
Copyright © 1999-2021 by the D Language Foundation