Expose Random Object as part of the test context
Bug #1111834 reported by
Tyrel Alastair Hunter
This bug affects 1 person
Affects | Status | Importance | Assigned to | Milestone | |
---|---|---|---|---|---|
NUnit Framework |
Fix Released
|
Wishlist
|
Charlie Poole | ||
NUnitLite |
Fix Released
|
Medium
|
Tyrel Alastair Hunter |
Bug Description
When you have a test that needs to generate randomness but the random attribute is not sufficient, there is no way to make sure that the same random number is used across multiple test executions. In order to fix this it would be ideal to expose the already existing Random generator that is part of each test case on the context.
Related branches
lp://staging/~ialastairhunter/nunitlite/categoryfilter
- Charlie Poole: Needs Fixing (code review)
-
Diff: 6121 lines (+3084/-2720)19 files modifiedsrc/framework/Api/ITest.cs (+103/-96)
src/framework/Api/ITestFilter.cs (+6/-1)
src/framework/Internal/Builders/NUnitTestCaseBuilder.cs (+406/-400)
src/framework/Internal/Filters/SimpleCategoryExpression.cs (+49/-0)
src/framework/Internal/RandomGenerator.cs (+184/-0)
src/framework/Internal/TestExecutionContext.cs (+622/-605)
src/framework/Internal/TestFilter.cs (+9/-1)
src/framework/Internal/Tests/Test.cs (+415/-404)
src/framework/Runner/CommandLineOptions.cs (+32/-2)
src/framework/Runner/TextUI.cs (+260/-237)
src/framework/TestContext.cs (+257/-249)
src/framework/nunitlite-2.0.csproj (+8/-6)
src/framework/nunitlite-3.5.csproj (+8/-6)
src/framework/nunitlite-4.0.csproj (+8/-6)
src/framework/nunitlite-4.5.csproj (+366/-364)
src/framework/nunitlite-netcf-2.0.csproj (+328/-326)
src/framework/nunitlite-netcf-3.5.csproj (+3/-1)
src/framework/nunitlite-sl-4.0.csproj (+10/-8)
src/framework/nunitlite-sl-5.0.csproj (+10/-8)
Changed in nunit-3.0: | |
assignee: | nobody → Wes Cutting (wesleycutting) |
Changed in nunitlite: | |
assignee: | nobody → Wes Cutting (wesleycutting) |
Changed in nunit-3.0: | |
assignee: | Wes Cutting (wesleycutting) → nobody |
Changed in nunitlite: | |
assignee: | Wes Cutting (wesleycutting) → Tyrel Alastair Hunter (ialastairhunter) |
Changed in nunit-3.0: | |
assignee: | nobody → Tyrel Alastair Hunter (ialastairhunter) |
Changed in nunit-3.0: | |
status: | Triaged → In Progress |
Changed in nunitlite: | |
status: | Triaged → In Progress |
Changed in nunitlite: | |
importance: | Wishlist → Medium |
milestone: | none → 0.9 |
Changed in nunitlite: | |
status: | In Progress → Fix Committed |
Changed in nunitlite: | |
status: | Fix Committed → Fix Released |
Changed in nunit-3.0: | |
assignee: | Tyrel Alastair Hunter (ialastairhunter) → Charlie Poole (charlie.poole) |
milestone: | none → 2.9.6 |
status: | In Progress → Fix Committed |
Changed in nunit-3.0: | |
status: | Fix Committed → Fix Released |
To post a comment you must log in.
Take care... you may _not_ want to use the same randomizer that NUnit
uses to create test cases for a method. That randomizer is used at the
time a test is loaded and is re-initialized each time we reload. If
you reuse it at run time, it will have different values each time the
tests are rerun. It may simply be better to create a new randomizer
each time a test is started. For efficiency, you could delay creation
until the test actually accessed that member of the context, so long
as you had the correct seed stored and ready for use.
Charlie
On Fri, Feb 8, 2013 at 12:44 PM, Wes Cutting <email address hidden> wrote: /bugs.launchpad .net/bugs/ 1111834 /bugs.launchpad .net/nunit- 3.0/+bug/ 1111834/ +subscriptions
> ** Changed in: nunit-3.0
> Assignee: (unassigned) => Wes Cutting (wesleycutting)
>
> ** Changed in: nunitlite
> Assignee: (unassigned) => Wes Cutting (wesleycutting)
>
> --
> You received this bug notification because you are subscribed to
> NUnitLite.
> https:/
>
> Title:
> Expose Random Object as part of the test context
>
> To manage notifications about this bug go to:
> https:/