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
[Random] currently supports several primitive types (mostly numeric ones), but it does not work with Guid. To provide different values to a Guid argument, one has to manually provide them either via [TestCaseSource] or via [ValueSource].
In my experience, being able to easily provide different Guid values to a test is fairly useful. Currently, I'm doing this by using a ValueSource, which caused a different problem, forcing me to resort to hardcoded Guids instead of using Guid.NewGuid.
I'm aware that Guid randomization is different than the standard one using the Random class, so I'm not sure if it would be possible to have the same "seed" in discovery and execution phases to build the unique test names with the built-in values (probably not).
The text was updated successfully, but these errors were encountered:
In the meantime, that suggests the workaround you could use. Instead of Guid.NewGuid(), use TestContext.CurrentContext.Random.NextGuid().
I guess you could then easily leverage this for generating the random Guid values in a consistent manner like any other random values are created today.
[Random]
currently supports several primitive types (mostly numeric ones), but it does not work withGuid
. To provide different values to aGuid
argument, one has to manually provide them either via[TestCaseSource]
or via[ValueSource]
.In my experience, being able to easily provide different
Guid
values to a test is fairly useful. Currently, I'm doing this by using aValueSource
, which caused a different problem, forcing me to resort to hardcodedGuid
s instead of usingGuid.NewGuid
.I'm aware that
Guid
randomization is different than the standard one using theRandom
class, so I'm not sure if it would be possible to have the same "seed" in discovery and execution phases to build the unique test names with the built-in values (probably not).The text was updated successfully, but these errors were encountered: