Skip to content

Sublte bug when missing unit argument in an F# fact #2064

@njlr

Description

@njlr

Suppose I have a test like this:

module MyTests

open Xunit

[<Fact>
let ``this test always fails`` = 
  Assert.True(false)

Then I can build and run my tests successfully with:

dotnet test

This is because the test is actually defined incorrectly and gets silently ignored by the test runner!

It should be:

module MyTests

open Xunit

[<Fact>
let ``this test always fails`` () = 
  Assert.True(false)

(Notice that the test is now a function by adding ())

This will compile and then fail as expected.

Ideally, the first version should not compile at all, thus avoiding this very subtle bug.

  nuget xunit 2.4.1
  nuget xunit.runner.console 2.4.1
  nuget xunit.runner.visualstudio 2.4.1

Metadata

Metadata

Assignees

No one assigned

    Labels

    ExternalThe issue is caused by an external party

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions