Closed joncloud closed 7 years ago
Is this still ongoing?
I'll review the code in its current state to see if its applicable, and run some more tests to make sure.
I ran a couple of dotnet test
runs, and got a failure on the second run. It looks like this may be due to xunit running the tests in parallel, and the way we have the tests written we're swapping some of the static context away.
There are a couple of options that I uncovered by adjusting the tests:
CollectionBehavior
(assembly level attribute) to disable test parallelization.Quick local test showed that disabling test parallelization increased test time by ~0.1s
@joncloud nice work. What static context are we manipulating?
Good point - I totally missed that the title of the issue had "Context". Check out the use of the Swap
class in the unit test project. We're using it to swap out Scientist.Enabled
and Scientist.ResultPublisher
.
Oh right. Static state is evil. But in this case, an intentional deal with the devil for simplicity and usability sake.
I like the changes you proposed. Let's do that for now and we can think about whether we want to change anything later.
I opted for running all tests in series rather than moving all of the tests around, because the of the simplicity. We can definitely expand in the future if we've added enough unit tests that make the run time too slow.
@joncloud that sounds reasonable. These tests are so fast anyways. :smile:
Fixed on #84.
Running build.cmd or tests through Visual Studio seems to occasionally fail due to an exception.
Test run on 43e27ee6b42fb6c34ec174df1b46a1b7137a13a8