mirror of
https://github.com/Smaug123/unofficial-nunit-runner
synced 2025-10-08 18:48:40 +00:00
Special NUnit exception types (#38)
This commit is contained in:
@@ -9,6 +9,7 @@
|
|||||||
|
|
||||||
<ItemGroup>
|
<ItemGroup>
|
||||||
<Compile Include="NoAttribute.fs" />
|
<Compile Include="NoAttribute.fs" />
|
||||||
|
<Compile Include="Inconclusive.fs" />
|
||||||
<Compile Include="TestSetUp.fs" />
|
<Compile Include="TestSetUp.fs" />
|
||||||
<Compile Include="TestValues.fs" />
|
<Compile Include="TestValues.fs" />
|
||||||
<None Include="some-config.json">
|
<None Include="some-config.json">
|
||||||
|
19
Consumer/Inconclusive.fs
Normal file
19
Consumer/Inconclusive.fs
Normal file
@@ -0,0 +1,19 @@
|
|||||||
|
namespace Consumer
|
||||||
|
|
||||||
|
open NUnit.Framework
|
||||||
|
|
||||||
|
[<TestFixture>]
|
||||||
|
module Inconclusive =
|
||||||
|
|
||||||
|
[<Test>]
|
||||||
|
let ``Inconclusive test`` () =
|
||||||
|
Assert.Inconclusive "I was inconclusive"
|
||||||
|
|
||||||
|
[<Test>]
|
||||||
|
let ``Ignore test`` () = Assert.Ignore "I am ignored"
|
||||||
|
|
||||||
|
[<Test>]
|
||||||
|
let ``Pass test`` () = Assert.Pass "ohhhh yeaahhhh"
|
||||||
|
|
||||||
|
[<Test>]
|
||||||
|
let ``Warning`` () = Assert.Warn "warning"
|
@@ -151,6 +151,8 @@ type TestMemberSuccess =
|
|||||||
| Ignored of reason : string option
|
| Ignored of reason : string option
|
||||||
/// We didn't run the test, because it's [<Explicit>].
|
/// We didn't run the test, because it's [<Explicit>].
|
||||||
| Explicit of reason : string option
|
| Explicit of reason : string option
|
||||||
|
/// We ran the test, and it performed Assert.Inconclusive.
|
||||||
|
| Inconclusive of reason : string option
|
||||||
|
|
||||||
/// Represents the failure of a test.
|
/// Represents the failure of a test.
|
||||||
[<RequireQualifiedAccess>]
|
[<RequireQualifiedAccess>]
|
||||||
|
@@ -221,27 +221,34 @@ TestRunner.TestMemberFailure.IsMalformed [property]: [read-only] bool
|
|||||||
TestRunner.TestMemberFailure.NewFailed [static method]: TestRunner.TestFailure list -> TestRunner.TestMemberFailure
|
TestRunner.TestMemberFailure.NewFailed [static method]: TestRunner.TestFailure list -> TestRunner.TestMemberFailure
|
||||||
TestRunner.TestMemberFailure.NewMalformed [static method]: string list -> TestRunner.TestMemberFailure
|
TestRunner.TestMemberFailure.NewMalformed [static method]: string list -> TestRunner.TestMemberFailure
|
||||||
TestRunner.TestMemberFailure.Tag [property]: [read-only] int
|
TestRunner.TestMemberFailure.Tag [property]: [read-only] int
|
||||||
TestRunner.TestMemberSuccess inherit obj, implements TestRunner.TestMemberSuccess System.IEquatable, System.Collections.IStructuralEquatable, TestRunner.TestMemberSuccess System.IComparable, System.IComparable, System.Collections.IStructuralComparable - union type with 3 cases
|
TestRunner.TestMemberSuccess inherit obj, implements TestRunner.TestMemberSuccess System.IEquatable, System.Collections.IStructuralEquatable, TestRunner.TestMemberSuccess System.IComparable, System.IComparable, System.Collections.IStructuralComparable - union type with 4 cases
|
||||||
TestRunner.TestMemberSuccess+Explicit inherit TestRunner.TestMemberSuccess
|
TestRunner.TestMemberSuccess+Explicit inherit TestRunner.TestMemberSuccess
|
||||||
TestRunner.TestMemberSuccess+Explicit.get_reason [method]: unit -> string option
|
TestRunner.TestMemberSuccess+Explicit.get_reason [method]: unit -> string option
|
||||||
TestRunner.TestMemberSuccess+Explicit.reason [property]: [read-only] string option
|
TestRunner.TestMemberSuccess+Explicit.reason [property]: [read-only] string option
|
||||||
TestRunner.TestMemberSuccess+Ignored inherit TestRunner.TestMemberSuccess
|
TestRunner.TestMemberSuccess+Ignored inherit TestRunner.TestMemberSuccess
|
||||||
TestRunner.TestMemberSuccess+Ignored.get_reason [method]: unit -> string option
|
TestRunner.TestMemberSuccess+Ignored.get_reason [method]: unit -> string option
|
||||||
TestRunner.TestMemberSuccess+Ignored.reason [property]: [read-only] string option
|
TestRunner.TestMemberSuccess+Ignored.reason [property]: [read-only] string option
|
||||||
|
TestRunner.TestMemberSuccess+Inconclusive inherit TestRunner.TestMemberSuccess
|
||||||
|
TestRunner.TestMemberSuccess+Inconclusive.get_reason [method]: unit -> string option
|
||||||
|
TestRunner.TestMemberSuccess+Inconclusive.reason [property]: [read-only] string option
|
||||||
TestRunner.TestMemberSuccess+Tags inherit obj
|
TestRunner.TestMemberSuccess+Tags inherit obj
|
||||||
TestRunner.TestMemberSuccess+Tags.Explicit [static field]: int = 2
|
TestRunner.TestMemberSuccess+Tags.Explicit [static field]: int = 2
|
||||||
TestRunner.TestMemberSuccess+Tags.Ignored [static field]: int = 1
|
TestRunner.TestMemberSuccess+Tags.Ignored [static field]: int = 1
|
||||||
|
TestRunner.TestMemberSuccess+Tags.Inconclusive [static field]: int = 3
|
||||||
TestRunner.TestMemberSuccess+Tags.Ok [static field]: int = 0
|
TestRunner.TestMemberSuccess+Tags.Ok [static field]: int = 0
|
||||||
TestRunner.TestMemberSuccess.get_IsExplicit [method]: unit -> bool
|
TestRunner.TestMemberSuccess.get_IsExplicit [method]: unit -> bool
|
||||||
TestRunner.TestMemberSuccess.get_IsIgnored [method]: unit -> bool
|
TestRunner.TestMemberSuccess.get_IsIgnored [method]: unit -> bool
|
||||||
|
TestRunner.TestMemberSuccess.get_IsInconclusive [method]: unit -> bool
|
||||||
TestRunner.TestMemberSuccess.get_IsOk [method]: unit -> bool
|
TestRunner.TestMemberSuccess.get_IsOk [method]: unit -> bool
|
||||||
TestRunner.TestMemberSuccess.get_Ok [static method]: unit -> TestRunner.TestMemberSuccess
|
TestRunner.TestMemberSuccess.get_Ok [static method]: unit -> TestRunner.TestMemberSuccess
|
||||||
TestRunner.TestMemberSuccess.get_Tag [method]: unit -> int
|
TestRunner.TestMemberSuccess.get_Tag [method]: unit -> int
|
||||||
TestRunner.TestMemberSuccess.IsExplicit [property]: [read-only] bool
|
TestRunner.TestMemberSuccess.IsExplicit [property]: [read-only] bool
|
||||||
TestRunner.TestMemberSuccess.IsIgnored [property]: [read-only] bool
|
TestRunner.TestMemberSuccess.IsIgnored [property]: [read-only] bool
|
||||||
|
TestRunner.TestMemberSuccess.IsInconclusive [property]: [read-only] bool
|
||||||
TestRunner.TestMemberSuccess.IsOk [property]: [read-only] bool
|
TestRunner.TestMemberSuccess.IsOk [property]: [read-only] bool
|
||||||
TestRunner.TestMemberSuccess.NewExplicit [static method]: string option -> TestRunner.TestMemberSuccess
|
TestRunner.TestMemberSuccess.NewExplicit [static method]: string option -> TestRunner.TestMemberSuccess
|
||||||
TestRunner.TestMemberSuccess.NewIgnored [static method]: string option -> TestRunner.TestMemberSuccess
|
TestRunner.TestMemberSuccess.NewIgnored [static method]: string option -> TestRunner.TestMemberSuccess
|
||||||
|
TestRunner.TestMemberSuccess.NewInconclusive [static method]: string option -> TestRunner.TestMemberSuccess
|
||||||
TestRunner.TestMemberSuccess.Ok [static property]: [read-only] TestRunner.TestMemberSuccess
|
TestRunner.TestMemberSuccess.Ok [static property]: [read-only] TestRunner.TestMemberSuccess
|
||||||
TestRunner.TestMemberSuccess.Tag [property]: [read-only] int
|
TestRunner.TestMemberSuccess.Tag [property]: [read-only] int
|
||||||
TestRunner.TestProgress inherit obj
|
TestRunner.TestProgress inherit obj
|
||||||
|
@@ -31,7 +31,7 @@ module TestFixture =
|
|||||||
(test : MethodInfo)
|
(test : MethodInfo)
|
||||||
(containingObject : obj)
|
(containingObject : obj)
|
||||||
(args : obj[])
|
(args : obj[])
|
||||||
: Result<unit, TestFailure list>
|
: Result<TestMemberSuccess, TestFailure list>
|
||||||
=
|
=
|
||||||
let rec runMethods
|
let rec runMethods
|
||||||
(wrap : UserMethodFailure -> TestFailure)
|
(wrap : UserMethodFailure -> TestFailure)
|
||||||
@@ -59,15 +59,30 @@ module TestFixture =
|
|||||||
| Error e -> Error [ e ]
|
| Error e -> Error [ e ]
|
||||||
| Ok () ->
|
| Ok () ->
|
||||||
|
|
||||||
let result = runMethods TestFailure.TestFailed [ test ] args
|
let result =
|
||||||
|
let result = runMethods TestFailure.TestFailed [ test ] args
|
||||||
|
|
||||||
|
match result with
|
||||||
|
| Ok () -> Ok None
|
||||||
|
| Error (TestFailure.TestFailed (UserMethodFailure.Threw (_, exc)) as orig) ->
|
||||||
|
match exc.GetType().FullName with
|
||||||
|
| "NUnit.Framework.SuccessException" -> Ok None
|
||||||
|
| "NUnit.Framework.IgnoreException" -> Ok (Some (TestMemberSuccess.Ignored (Option.ofObj exc.Message)))
|
||||||
|
| "NUnit.Framework.InconclusiveException" ->
|
||||||
|
Ok (Some (TestMemberSuccess.Inconclusive (Option.ofObj exc.Message)))
|
||||||
|
| s when s.StartsWith ("NUnit.Framework.", StringComparison.Ordinal) ->
|
||||||
|
failwith $"Unrecognised special exception: %s{s}"
|
||||||
|
| _ -> Error orig
|
||||||
|
| Error orig -> Error orig
|
||||||
|
|
||||||
// Unconditionally run TearDown after tests, even if tests failed.
|
// Unconditionally run TearDown after tests, even if tests failed.
|
||||||
let tearDownResult = runMethods TestFailure.TearDownFailed tearDown [||]
|
let tearDownResult = runMethods TestFailure.TearDownFailed tearDown [||]
|
||||||
|
|
||||||
match result, tearDownResult with
|
match result, tearDownResult with
|
||||||
| Ok (), Ok () -> Ok ()
|
| Ok None, Ok () -> Ok TestMemberSuccess.Ok
|
||||||
|
| Ok (Some s), Ok () -> Ok s
|
||||||
| Error e, Ok ()
|
| Error e, Ok ()
|
||||||
| Ok (), Error e -> Error [ e ]
|
| Ok _, Error e -> Error [ e ]
|
||||||
| Error e1, Error e2 -> Error [ e1 ; e2 ]
|
| Error e1, Error e2 -> Error [ e1 ; e2 ]
|
||||||
|
|
||||||
let private getValues (test : SingleTestMethod) =
|
let private getValues (test : SingleTestMethod) =
|
||||||
@@ -140,11 +155,11 @@ module TestFixture =
|
|||||||
| Ok values ->
|
| Ok values ->
|
||||||
|
|
||||||
let inline normaliseError
|
let inline normaliseError
|
||||||
(e : Result<unit, TestFailure list>)
|
(e : Result<TestMemberSuccess, TestFailure list>)
|
||||||
: Result<TestMemberSuccess, TestMemberFailure>
|
: Result<TestMemberSuccess, TestMemberFailure>
|
||||||
=
|
=
|
||||||
match e with
|
match e with
|
||||||
| Ok () -> Ok TestMemberSuccess.Ok
|
| Ok s -> Ok s
|
||||||
| Error e -> Error (e |> TestMemberFailure.Failed)
|
| Error e -> Error (e |> TestMemberFailure.Failed)
|
||||||
|
|
||||||
match test.Kind, values with
|
match test.Kind, values with
|
||||||
|
@@ -1,5 +1,5 @@
|
|||||||
{
|
{
|
||||||
"version": "0.3",
|
"version": "0.4",
|
||||||
"publicReleaseRefSpec": null,
|
"publicReleaseRefSpec": null,
|
||||||
"pathFilters": [
|
"pathFilters": [
|
||||||
"./",
|
"./",
|
||||||
|
Reference in New Issue
Block a user