You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Hi, I'm very new to property based testing and to your library, thanks for creating it! I have a question about the seeds when using multiple Generators. I have made this small example which highlights my issue:
public class Dummy
{
private readonly int[] m_Single;
public Dummy(int range)
{
m_Single = Gen.Int[0, 10].Array[range].Single();
}
public void DoSomething()
{
if (m_Single.Sum() % 2 == 0)
{
Assert.IsTrue(false);
}
}
}
public static class GenHelper
{
public static Gen<Dummy> GenDummy => Gen.Select(Gen.Int[1, 512], x => new Dummy(x));
}
[TestMethod]
public void seed_test()
{
GenHelper.GenDummy.Sample(d => d.DoSomething(), null, null, -1, -1, -1);
}
When I run this test, it fails and gives me a seed, but I'm unsure if it 'belongs' to the Sample or Single method. For example, I got this seed: 00007TA2XpFw, when I provide it to both Sample and Single, the test succeeds again. When I provide it only to Sample and then run the test again it sometimes succeeds and sometimes fails with a different hash. If I provide the last hash to Single it fails every time as expected.
My real use-case has a lot more generators, so trying these different seeds for different Generators is not that feasible. Perhaps I am misunderstanding how to use the seed? Thanks!
The text was updated successfully, but these errors were encountered:
Hi,
You can't use Sample and Single together. Single is meant to be just a quick way of creating a random value when it doesn't matter what the value is so it doesn't work with the Sample seed but it's own. I'll make this more clear on the Single method.
In the example above instead of using Single you can create a Gen and Use Gen.SelectMany instead of Gen.Select.
Hi, I'm very new to property based testing and to your library, thanks for creating it! I have a question about the seeds when using multiple Generators. I have made this small example which highlights my issue:
When I run this test, it fails and gives me a seed, but I'm unsure if it 'belongs' to the
Sample
orSingle
method. For example, I got this seed:00007TA2XpFw
, when I provide it to bothSample
andSingle
, the test succeeds again. When I provide it only toSample
and then run the test again it sometimes succeeds and sometimes fails with a different hash. If I provide the last hash toSingle
it fails every time as expected.My real use-case has a lot more generators, so trying these different seeds for different Generators is not that feasible. Perhaps I am misunderstanding how to use the seed? Thanks!
The text was updated successfully, but these errors were encountered: