Skip to content

F# - async tests don't actually run (false positive) #3984

@jwosty

Description

@jwosty

I can't get TUnit to run F# async tests at all. To reproduce: just take any async example from the docs, or template projects, and try to make them fail, and observe that they do not (they indicate as passing):

member this.ThisTestShouldFail() = async {
    let result = 0 - 1
    do! check (Assert.That(result).IsPositive())
}

However if you change it to use Task instead, it indeed fails as expected:

let checkT (assertion: Assertion<'T>) = assertion.AssertAsync() :> Task

member this.ThisTestShouldFail() = task {
    let result = 0 - 1
    do! checkT (Assert.That(result).IsPositive())
}

Or explicitly use Async.RunSynchronously:

member this.ThisTestShouldFail() = Async.RunSynchronously <| async {
    let result = 0 - 1
    do! check (Assert.That(result).IsPositive())
}

I'm using .NET 10, TUnit 1.3.25, and TUnit.Assertions.FSharp 1.3.25.

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions