Skip to content

Setting Random Seed using --site option has no effect #1823

@CharliePoole

Description

@CharliePoole

Normally, the NUnit framework generates a new set of values for test parameters marked up with [Random] on each separate execution. It does this by generating a random seed value for each assembly and using it to initialize its internal Randomizer class.

The console option --seed is used to add a RandomSeed property to the package, which is respected by the framework and used to bypass the creation of a new seed value. This allows tests to be repeated with the same random arguments being generated as was used in a prior run. The engine feature supporting it is also used by other runners that in particular GUI runners like the VS adapter and TestCentric.

The feature continues to function in the 3.22 build of the engine and console runner but is failing in the current V4 build. I used the following test to confirm the problem...

    public class RandomDataTests
    {
        [Test]
        public void SingleRandomParameter([Random(1, 100, 10)] int num)
        {
            Assert.That(num * 2, Is.EqualTo(num + num));
        }
    }

Running this test using the command-line options '--seed:12345 --labels:Afterproduced a display showing completely different values for thenumparameter on each execution. In addition, theRandomSeed` property is not displayed by the runner, which may be be a side-effect of this issue or may be caused by a separate error.

@rowo360 This needs to be resolved before the corresponding TestCentric feature will work correctly.

Metadata

Metadata

Assignees

Type

No type

Projects

No projects

Relationships

None yet

Development

No branches or pull requests

Issue actions