mirror of
https://github.com/Smaug123/unofficial-nunit-runner
synced 2025-10-08 18:48:40 +00:00
Cope with test fixtures which have non-static members (#22)
This commit is contained in:
@@ -15,6 +15,7 @@
|
||||
</None>
|
||||
<Compile Include="TestAppDomain.fs" />
|
||||
<Compile Include="TestCaseData.fs" />
|
||||
<Compile Include="TestNonStatic.fs" />
|
||||
</ItemGroup>
|
||||
|
||||
<ItemGroup>
|
||||
|
31
Consumer/TestNonStatic.fs
Normal file
31
Consumer/TestNonStatic.fs
Normal file
@@ -0,0 +1,31 @@
|
||||
namespace Consumer
|
||||
|
||||
open System.Threading
|
||||
open FsUnitTyped
|
||||
open NUnit.Framework
|
||||
|
||||
[<RequireQualifiedAccess>]
|
||||
module NonStaticTestHelpers =
|
||||
let count = ref 0
|
||||
|
||||
[<TestFixture>]
|
||||
type TestNonStatic () =
|
||||
let count = ref 0
|
||||
|
||||
member this.Thing = "i'm a thing"
|
||||
|
||||
[<Test>]
|
||||
member this.Foo () =
|
||||
Interlocked.Increment NonStaticTestHelpers.count |> ignore<int>
|
||||
Interlocked.Increment count |> ignore<int>
|
||||
this.Thing |> shouldEqual "i'm a thing"
|
||||
|
||||
[<Test>]
|
||||
static member AnotherTest () =
|
||||
Interlocked.Increment NonStaticTestHelpers.count |> ignore<int>
|
||||
1 |> shouldEqual 1
|
||||
|
||||
[<OneTimeTearDown>]
|
||||
member _.TearDown () =
|
||||
count.Value |> shouldEqual 1
|
||||
NonStaticTestHelpers.count.Value |> shouldEqual 2
|
Reference in New Issue
Block a user