Skip to content

Conversation

Copy link

Copilot AI commented Feb 11, 2026

xUnit tests with InlineData containing floating point numbers display garbled names in Test Explorer (e.g., "25)" instead of "(multiplicand: 0.5, multiplier: 0.5, expectedValue: 0.25)").

Root Cause

The DisplayName parser splits on . to extract theory case parameters:

let theoryCaseFragment = dto.DisplayName.Split('.') |> Array.last

This incorrectly splits on decimal points in float values. For DisplayName:

"MyModule.multiply.Test(multiplicand: 0.5, multiplier: 0.5, expectedValue: 0.25)"

The split produces: ["MyModule"; "multiply"; "Test(multiplicand: 0"; "5, multiplier: 0"; "5, expectedValue: 0"; "25)"]

Taking the last element yields "25)".

Changes

  • Extract parameter portion using Substring after removing FullName prefix
  • Preserve fallback to original behavior for edge cases where DisplayName doesn't start with FullName
let theoryCaseFragment =
    if dto.DisplayName.StartsWith(dto.FullName) then
        dto.DisplayName.Substring(dto.FullName.Length)
    else
        dto.DisplayName.Split('.') |> Array.last
Original prompt

This section details on the original issue you should resolve

<issue_title>Problems with xUnit Test Explorer test names in VS Code with F#.</issue_title>
<issue_description>### Describe the bug
Sometimes, when I use the “Refresh Tests” button in the “Testing” panel whereupon I get some strange test names. Some of the test names look correct while others look really wrong, e.g. “25)”, “320000000000001)”, “5, expectedValue: 0)”.

Steps to reproduce

Here's some code which exhibits the behaviour:

module multiply =

    [<Theory>]
    [<InlineData(0.0, 0.0, 0.0)>] 
    [<InlineData(0.0, 1.0, 0.0)>] 
    [<InlineData(1.0, 0.0, 0.0)>] 
    [<InlineData(1.0, 1.0, 1.0)>] 
    [<InlineData(0.0, 0.5, 0.0)>] 
    [<InlineData(0.5, 0.5, 0.25)>] 
    [<InlineData(0.8, 0.4, 0.32)>] 

    let ``Returns expected value`` (multiplicand : float) (multiplier : float) (expectedValue : float) = 

        let result = multiplicand * multiplier 

        Assert.Equal(expectedValue, result)

Link to sample reproduction

No repository available.

Expected behaviour

I would expect the test names to be as specified in the code.

Screenshots

Screenshot and more information here: https://fsharp.slack.com/archives/C04BJKUP2/p1770631977461249

Machine info

I’m using VS Code (1.109.0), Ionide (7.31.1), F# 9.0.3 with an xUnit (2.9.2) test project on a Windows 10 machine.

Additional context

I’ve tried moving the test out of the module but the problem persists.
I’ve tried reordering the InlineData but the problem persists.
I’ve tried using [<MemberData(nameof(testData))>] instead of InlineData but the problem persists.
I’ve tried restoring the test project but the problem persists.
I’ve tried typing the whole thing again without copy/paste but the problem persists.
I’ve tried cleaning out the previous test results but the problem persists.
...and various combinations of the above.

The tests seem to run okay but the names in the test explorer aren’t useful.

Just out of interest, I tried a different approach with:

type MultiplyTestData = { Multiplicand : float ; Multiplier : float ; ExpectedValue : float }

let testData : obj[] list =
[
[| { Multiplicand = 0.0 ; Multiplier = 0.0 ; ExpectedValue = 0.0 } |]
[| { Multiplicand = 0.0 ; Multiplier = 1.0 ; ExpectedValue = 0.0 } |]
[| { Multiplicand = 1.0 ; Multiplier = 0.0 ; ExpectedValue = 0.0 } |]
[| { Multiplicand = 1.0 ; Multiplier = 1.0 ; ExpectedValue = 1.0 } |]
]

[<Theory>]
[<MemberData(nameof(testData))>]

let ``Returns expected value`` { Multiplicand = multiplicand ; Multiplier = multiplier ; ExpectedValue = expectedValue } =

let result = multiplicand * multiplier

Assert.Equal(expectedValue, result)

…but I got the error:

The test run errored
Error: An item with the same key has already been added. Key: c:\<somewhere>\Tests.fsproj -- MyTests+multiply.Returns expected value
```</issue_description>

## Comments on the Issue (you are @copilot in this section)

<comments>
</comments>


💡 You can make Copilot smarter by setting up custom instructions, customizing its development environment and configuring Model Context Protocol (MCP) servers. Learn more Copilot coding agent tips in the docs.

Copilot AI and others added 2 commits February 11, 2026 15:15
Co-authored-by: TheAngryByrd <1490044+TheAngryByrd@users.noreply.github.com>
Co-authored-by: TheAngryByrd <1490044+TheAngryByrd@users.noreply.github.com>
Copilot AI changed the title [WIP] Fix incorrect test names in xUnit Test Explorer Fix xUnit test name parsing with floating point parameters Feb 11, 2026
Copilot AI requested a review from TheAngryByrd February 11, 2026 15:18
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Problems with xUnit Test Explorer test names in VS Code with F#.

2 participants