mirror of
https://github.com/Smaug123/unofficial-nunit-runner
synced 2025-10-08 10:38:41 +00:00
Parallelize (#69)
This commit is contained in:
@@ -10,7 +10,9 @@ module TestParallelDefault =
|
||||
let defaults = List.init 100 id
|
||||
|
||||
[<TestCaseSource(nameof defaults)>]
|
||||
let ``Default thing`` (i : int) = i |> shouldEqual i
|
||||
let ``Default thing`` (i : int) =
|
||||
System.Console.WriteLine i
|
||||
i |> shouldEqual i
|
||||
|
||||
[<TestFixture>]
|
||||
[<Parallelizable(ParallelScope.All)>]
|
||||
@@ -19,7 +21,9 @@ module TestParallelAllScope =
|
||||
let defaults = List.init 100 id
|
||||
|
||||
[<TestCaseSource(nameof defaults)>]
|
||||
let ``Default thing`` (i : int) = i |> shouldEqual i
|
||||
let ``Default thing`` (i : int) =
|
||||
System.Console.WriteLine i
|
||||
i |> shouldEqual i
|
||||
|
||||
[<TestFixture>]
|
||||
[<Parallelizable(ParallelScope.Self)>]
|
||||
@@ -28,7 +32,9 @@ module TestParallelSelfScope =
|
||||
let defaults = List.init 100 id
|
||||
|
||||
[<TestCaseSource(nameof defaults)>]
|
||||
let ``Default thing`` (i : int) = i |> shouldEqual i
|
||||
let ``Default thing`` (i : int) =
|
||||
System.Console.WriteLine i
|
||||
i |> shouldEqual i
|
||||
|
||||
[<TestFixture>]
|
||||
[<Parallelizable(ParallelScope.Children)>]
|
||||
@@ -37,7 +43,9 @@ module TestParallelChildrenScope =
|
||||
let defaults = List.init 100 id
|
||||
|
||||
[<TestCaseSource(nameof defaults)>]
|
||||
let ``Default thing`` (i : int) = i |> shouldEqual i
|
||||
let ``Default thing`` (i : int) =
|
||||
System.Console.WriteLine i
|
||||
i |> shouldEqual i
|
||||
|
||||
[<TestFixture>]
|
||||
[<Parallelizable(ParallelScope.Fixtures)>]
|
||||
@@ -46,4 +54,6 @@ module TestParallelFixturesScope =
|
||||
let defaults = List.init 100 id
|
||||
|
||||
[<TestCaseSource(nameof defaults)>]
|
||||
let ``Default thing`` (i : int) = i |> shouldEqual i
|
||||
let ``Default thing`` (i : int) =
|
||||
System.Console.WriteLine i
|
||||
i |> shouldEqual i
|
||||
|
@@ -1,5 +1,6 @@
|
||||
namespace Consumer
|
||||
|
||||
open System
|
||||
open FsUnitTyped
|
||||
open System.Threading
|
||||
open NUnit.Framework
|
||||
@@ -11,6 +12,8 @@ module TestSetUp =
|
||||
|
||||
[<OneTimeSetUp>]
|
||||
let oneTimeSetUp () =
|
||||
Console.WriteLine "I'm being set up for the first time!"
|
||||
|
||||
if Interlocked.Increment haveOneTimeSetUp <> 1 then
|
||||
failwith "one time setup happened more than once"
|
||||
|
||||
@@ -22,12 +25,14 @@ module TestSetUp =
|
||||
|
||||
[<SetUp>]
|
||||
let setUp () =
|
||||
Console.WriteLine "It's a set-up!"
|
||||
haveOneTimeSetUp.Value |> shouldEqual 1
|
||||
let newId = Interlocked.Increment setUpTimes
|
||||
lock setUpTimesSeen (fun () -> setUpTimesSeen.Add newId)
|
||||
|
||||
[<TearDown>]
|
||||
let tearDown () =
|
||||
Console.WriteLine "I'm a tear-down!"
|
||||
let newId = Interlocked.Increment tearDownTimes
|
||||
lock tearDownTimesSeen (fun () -> tearDownTimesSeen.Add newId)
|
||||
|
||||
@@ -35,6 +40,8 @@ module TestSetUp =
|
||||
|
||||
[<OneTimeTearDown>]
|
||||
let oneTimeTearDown () =
|
||||
Console.WriteLine "I'm being torn down, finally!"
|
||||
|
||||
if Interlocked.Increment haveOneTimeTearDown <> 1 then
|
||||
failwith "one time tear down happened more than once"
|
||||
|
||||
@@ -48,6 +55,7 @@ module TestSetUp =
|
||||
[<Test>]
|
||||
let ``Test 1`` () =
|
||||
haveOneTimeTearDown.Value |> shouldEqual 0
|
||||
Console.WriteLine "By the way, I'm test 1"
|
||||
1 |> shouldEqual 1
|
||||
|
||||
[<TestCase "h">]
|
||||
|
Reference in New Issue
Block a user