TUnit icon indicating copy to clipboard operation
TUnit copied to clipboard

Test overview in rider show wrong test details for test executions

Open TheRumle opened this issue 11 months ago • 5 comments

I have noticed a few funny things both when creating fixtures using DataSourceGenerators. It seems like the test execution shown in the IDE is not the same as what is actually run. I have verified that this does not happen when running through console, so the tests are running correctly. However, seeing that test data does not correlate with what is shown as failing can and will scare user.

Shows data correctly in IDE

  • [x] When data is injected through constructor
  • [ ] When data is injected through method
  • [x] Other?

Recreation

TUNIT: 0.18.60 Jetbrains Rider:

  • JetBrains Rider 2025.1 EAP 8, Build #RD-251.23774.118, built on March 14, 2025
  • JetBrains Rider 2024.3.6, Build #RD-243.25659.34, built on February 27, 2025

I have enabled Testing Platform Support as stated on riders own site..

Generator for test ints

public class RandomNumberFixtureGenerator : DataSourceGeneratorAttribute<int>
{
    public override IEnumerable<Func<int>> GenerateDataSources(DataGeneratorMetadata dataGeneratorMetadata)
    {
        var random = new Random();
        return Enumerable.Range(0,10).Select(_ => new Func<int>(random.Next));
    }
}

Method injection (shows wrong in IDE)

[Category("Method")]
public class NumberTestMethodInjection
{
    [Test]
    [RandomNumberFixtureGenerator]
    [DisplayName("Number generated $number")]
    public async Task IsEven(int number)
    {
        Console.WriteLine(number);
        await Assert.That(number % 2 == 0).IsTrue();
    }
}

Constructor injection (shows up correctly in IDE)

[RandomNumberFixtureGenerator]
[Category("Constructor")]
public class NumberTestCTorInjection(int number)
{

    /// <inheritdoc />
    public override string ToString()
    {
        return number.ToString();
    }

    [Test]
    public async Task IsEven()
    {
        Console.WriteLine(this);
        Console.WriteLine(number);
        await Assert.That(number % 2 == 0).IsTrue();
    }
}

Proof

Constructor injection

This works just fine - the data shown in the list of test executions and the logs show that the details in the list and the actual data used matches. Image

Method injection (wrong!)

The failed execution highlighted shows that the test should have been wrong with input 1008109009, but the logs shows it was actually run with 1858300199 Image

The successful execution highlighted shows that the test should have been wrong with input 20181705, but the logs shows it was actually run with 1676999926 Image

TheRumle avatar Mar 23 '25 09:03 TheRumle

Would you be able to raise this on Jetbrains as a rider issue?

thomhurst avatar Mar 23 '25 09:03 thomhurst

Would you be able to raise this on Jetbrains as a rider issue?

I have created an issue on YouTrack, in case you want to follow along

TheRumle avatar Mar 23 '25 19:03 TheRumle

This issue is stale because it has been open 30 days with no activity. Remove stale label or comment or this will be closed in 5 days.

github-actions[bot] avatar Apr 23 '25 00:04 github-actions[bot]

@thomhurst Would it be beneficial to leave this up for others to see, or should this be moved to stale?

TheRumle avatar Apr 23 '25 17:04 TheRumle

This issue is stale because it has been open 30 days with no activity. Remove stale label or comment or this will be closed in 5 days.

github-actions[bot] avatar May 24 '25 00:05 github-actions[bot]

This issue is stale because it has been open 30 days with no activity. Remove stale label or comment or this will be closed in 5 days.

github-actions[bot] avatar Jun 24 '25 00:06 github-actions[bot]

This issue was closed because it has been stalled for 5 days with no activity.

github-actions[bot] avatar Jun 29 '25 00:06 github-actions[bot]