nunit / nunit3-vs-adapter

NUnit 3.0 Visual Studio test adapter for use under VS 2012 or later
https://nunit.org
MIT License
205 stars 106 forks source link

Splitting a test with a TestCaseSource and ignoring test cases #1174

Closed bookofproofs closed 5 months ago

bookofproofs commented 6 months ago

This is F#:

namespace FplInterpreter.Tests
open NUnit.Framework

type SomeUnion = 
    | A 
    | B

[<Class>]
type TestCaseSourceNunit() =

    static member BaseCases = [
        yield ("true", A)
        yield ("false", A)
        yield ("undef", A)
        yield ("1.", A)
        yield ("del.Test()", A)
        yield ("$1", A)
        yield ("bydef Test()", A)             
        yield ("Test$1", A)            
        yield ("Test$1()", A)            
        yield ("Test", A)        
        yield ("v", A)
        yield ("self", A)
        yield ("1", A)
        yield ("v.x", A)
        yield ("self.x", A)
        yield ("Test()", A)
        yield ("v()", A)
        yield ("self()", A)
        yield ("1()", A)
        yield ("Test(x,y)", A)
        yield ("v(x,y)", A)
        yield ("self(x,y)", B)
        yield ("1(x,y)", B)
        yield ("Test[x,y]", B)
        yield ("v[x,y]", B)
        yield ("self[x,y]", B)
        yield ("1[x.y]", B)
        yield ("Test(x,y).@self[a,b]", B)        
        yield ("v(x,y).x[a,b]", B)            
        yield ("self(x,y).3[a,b)", B)
        yield ("1(x,y).T[a,b)", B)
        yield ("Test[x,y).x(a,b)", B)
        yield ("v[x,y).x(a,b)", A)
        yield ("self[x,y).self(a,b)", B)
        yield ("1[x.y).T(a,b)", B)
        yield ("∅", B)
        yield ("-x", A)
        yield ("-(y + x = 2 * x)", B)
        yield ("(y + x' = 2 * x)'", B)
        yield ("ex x in Range(a,b), y in c, z {and (a,b,c)}", B)
        yield ("exn$1 x {all y {true}}", A)
        yield ("all x {not x}", B)
        yield ("and (x,y,z)", B)
        yield ("xor (x,y,z)", B)
        yield ("or (x,y,z)", B)
        yield ("iif (x,y)", B)
        yield ("impl (x,y)", B)
        yield ("is (x,Nat)", B)
    ]

    [<Test>]
    [<TestCaseSource("BaseCases")>]
    member this.TestBaseCase(var: string * SomeUnion) =
        Assert.That(true)

NUnit will discover 40 (instead of 48) test cases and split the TestBaseCase into five different tests:

image

OsirisTerje commented 6 months ago

I suspect this is part of the same naming issues we have on the testcases (and testcasesources). I am no F# dev, so would appreciate of you could upload a working F# project with the code above.