-
Notifications
You must be signed in to change notification settings - Fork 238
Open
Description
Description
Currently, S3433 is reported when a data-driven test method in MSTest has a generic type parameter.
This is effectively supported by MSTest, so S3433 should not be reported.
Reproducer
Compile the following class with MSTest and S3433 enabled:
using System;
using System.Collections.Generic;
using Microsoft.VisualStudio.TestTools.UnitTesting;
[TestClass]
public sealed class SonarBug
{
[TestMethod]
[DynamicData(nameof(GetNameOfT_TestData))]
public void GetNameOfT<T>(T value, string expected)
where T : struct, Enum
{
var actual = Enum.GetName(value);
Assert.AreEqual(expected, actual);
}
private static IEnumerable<object?[]> GetNameOfT_TestData()
{
yield return [DateTimeKind.Local, "Local"];
yield return [DateTimeKind.Utc, "Utc"];
}
}Expected result:
S3433 is not reported. When you run the test you'll get two test results.
Actual result:
S3433 is reported.
Product and Version
SonarAnalyzer.CSharp v10.18.0.131500
Reactions are currently unavailable
Metadata
Metadata
Assignees
Labels
No labels