FP: Add some tests to this class


we are seeing a FP report in one of our test classes. the C# scanner does not seem to recognize the DataTestMethod attribute.

using Microsoft.VisualStudio.TestTools.UnitTesting;
using ***.ValueConverters;

namespace ***.Client.Test.ValueConverters
    public class NumericComparisonToBoolConverterTest
        /// <summary>
        /// Test Class for <see cref="NumericComparisonToBoolConverter"/> class
        /// </summary>
        public class ZeroToTrueBooleanConverterTest
            [DataRow("I'm not zero")]  // String
            [DataRow(null)]  // null
            [DataRow(-1)]  // Lesser
            [DataRow(0)]  // Equal
            [DataRow(1)]  // Greater
            public void NoneReturnsFalse(object objectInQuestion)

                var converter = new NumericComparisonToBoolConverter
                    ComparisonNumber = 0,
                    ComparisonType = NumericComparisonToBoolConverter.NumericComparisonType.None
                var result = converter.Convert(objectInQuestion, null, null, null);

                Assert.IsTrue(result is bool);

The above code presents us with the following code smell.

My suggestion is to treat DataTestMethod just the way you treat TestMethod.

Best regards

Hello @norberth

Thank you for taking the time to report this!

We have a test case with DataTestMethod and it seems to be supported from our side.

I cannot repro. Could you please give more details about your setup?

  • what is the version of Scanner for NET you are using?
  • what version of MSTest / Microsoft.NET.Test.Sdk are you using?
  • what is the version of MSBuild you are using?

Hi @Andrei_Epure ,

my mistake - I didn’t realize that the above code has a nested test class :frowning:
The outer class indeed does not have any tests.

We can consider this closed…

Best regards

1 Like

This topic was automatically closed 7 days after the last reply. New replies are no longer allowed.