mirror of
https://github.com/Smaug123/unofficial-nunit-runner
synced 2025-10-05 17:38:40 +00:00
Compare commits
2 Commits
WoofWare.N
...
failing-te
Author | SHA1 | Date | |
---|---|---|---|
|
71d340d33a | ||
|
c09eb93b5e |
@@ -10,6 +10,7 @@
|
||||
<Compile Include="NoAttribute.fs" />
|
||||
<Compile Include="Inconclusive.fs" />
|
||||
<Compile Include="RunSubProcess.fs" />
|
||||
<Compile Include="TestContext.fs" />
|
||||
<Compile Include="TestNonParallel.fs" />
|
||||
<Compile Include="TestParallel.fs" />
|
||||
<Compile Include="TestStdout.fs" />
|
||||
|
27
Consumer/TestContext.fs
Normal file
27
Consumer/TestContext.fs
Normal file
@@ -0,0 +1,27 @@
|
||||
namespace Consumer
|
||||
|
||||
open FsUnitTyped
|
||||
open NUnit.Framework
|
||||
|
||||
[<TestFixture>]
|
||||
module TestContext =
|
||||
|
||||
[<TestCase 3>]
|
||||
let ``Context has appropriate values`` (i : int) =
|
||||
// We explicitly cannot support this (https://github.com/dotnet/dotnet-api-docs/pull/3869/files).
|
||||
// TestContext.Progress.WriteLine "hi!"
|
||||
|
||||
TestContext.CurrentContext.Test.MethodName
|
||||
|> shouldEqual "Context has appropriate values"
|
||||
|
||||
TestContext.CurrentContext.Test.Name
|
||||
|> shouldEqual "Context has appropriate values(3)"
|
||||
|
||||
TestContext.CurrentContext.Test.Namespace |> shouldEqual "Consumer"
|
||||
TestContext.CurrentContext.Test.ClassName |> shouldEqual "Consumer.TestContext"
|
||||
|
||||
TestContext.CurrentContext.Test.FullName
|
||||
|> shouldEqual "Consumer.TestContext.Context has appropriate values(3)"
|
||||
|
||||
i |> shouldEqual 3
|
||||
TestContext.CurrentContext.Test.Arguments |> List.ofArray |> shouldEqual [ 3 ]
|
@@ -14,3 +14,8 @@ However, we would recommend phrasing some of them differently, for maximum peace
|
||||
WoofWare.NUnitTestRunner has *limited* support for parallelism.
|
||||
By default, we run tests serially; we may or may not respect the NUnit parallelism attributes to any given extent (but we will never incorrectly run tests in parallel).
|
||||
For example, as of this writing, we do not run any tests in parallel (but the internal infrastructure is set up so that we will be able to do this soon).
|
||||
|
||||
## `TestContext`
|
||||
|
||||
WoofWare.NUnitTestRunner has partial support for NUnit's `TestContext`.
|
||||
See [the test file](./Consumer/TestContext.fs) for everything we expect to work.
|
||||
|
@@ -71,6 +71,18 @@ public class StartupHookLogic
|
||||
using var contexts = TestContexts.Empty();
|
||||
Console.SetOut(contexts.Stdout);
|
||||
Console.SetError(contexts.Stderr);
|
||||
|
||||
var nunitAssembly = Assembly.Load("NUnit.Framework");
|
||||
if (object.ReferenceEquals(nunitAssembly, null))
|
||||
{
|
||||
throw new Exception("Could not load NUnit.Framework");
|
||||
}
|
||||
|
||||
var testContext = nunitAssembly.DefinedTypes.First(t => t.FullName == "NUnit.Framework.TestContext") ?? throw new Exception("Could not find TestContext type");
|
||||
var currentContextField = testContext.GetField("CurrentContext", BindingFlags.Static | BindingFlags.Public) ?? throw new Exception("Could not find CurrentContext field on TestContext");
|
||||
var currentContext = currentContextField.GetValue(null) ?? throw new Exception("Could not obtain value of CurrentContext");
|
||||
currentContextField.SetValue(currentContext, currentContext);
|
||||
|
||||
var results =
|
||||
Task.WhenAll(testFixtures.Select(x =>
|
||||
TestFixtureModule.run(contexts, par, TestProgress.toWriter(normalErr), filter, x)));
|
||||
|
Reference in New Issue
Block a user