question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

Suggestions to use fluent assertions instead of MSTest Asserts do not work if "using Microsoft.VisualStudio.TestTools.UnitTesting;" is located inside of the namespace.

See original GitHub issue

Description

Newly added functionality enabling easy move from MSTest Asserts to fluent assertions does not work if “using Microsoft.VisualStudio.TestTools.UnitTesting;” is located inside of the namespace.

Complete minimal example reproducing the issue

This will get a suggestion:

using Microsoft.VisualStudio.TestTools.UnitTesting;

namespace TestProject1
{
    [TestClass]
    public class UnitTest1
    {
        [TestMethod]
        public void TestMethod1()
        {
            Assert.AreEqual(1, 1);
        }
    }
}

But this will not:

namespace TestProject1
{
    using Microsoft.VisualStudio.TestTools.UnitTesting;

    [TestClass]
    public class UnitTest1
    {
        [TestMethod]
        public void TestMethod1()
        {
            Assert.AreEqual(1, 1);
        }
    }
}

Expected behavior:

Suggestion to use fluent assertions instead of Assert is shown when “using Microsoft.VisualStudio.TestTools.UnitTesting;” is located inside of the namespace.

Actual behavior:

Suggestion to use fluent assertions instead of Assert is not shown when “using Microsoft.VisualStudio.TestTools.UnitTesting;” is located inside of the namespace.

Versions

  • Which version of Fluent Assertions Analyzers are you using? FluentAssertions.Analyzers 0.16.0
  • Which .NET runtime and version are you targeting? .NET Core 3.1.

Issue Analytics

  • State:closed
  • Created a year ago
  • Comments:8 (4 by maintainers)

github_iconTop GitHub Comments

1reaction
Meir017commented, Apr 1, 2022

@robertMSFTE should be working now with version 0.17.2

1reaction
Meir017commented, Apr 1, 2022

@robertMSFTE just published version 0.17.1 with fixed package

Read more comments on GitHub >

github_iconTop Results From Across the Web

Tips - Fluent Assertions
The examples below show how you might improve your existing assertions to both get more readable assertions and much more informative failure messages....
Read more >
Use Assert classes for unit testing - Visual Studio
Learn how to use Assert statements to test the correctness of your code behavior during a unit test of your application code.
Read more >
Fluent Assertions Vs MS Test Assertions
Introduction This document talks about how we tackle unit and integration tests using MS Test assertions and Fluent Assertions.
Read more >
How do I use Assert to verify that an exception has been ...
How do I use Assert (or other Test class) to verify that an exception has been thrown when using MSTest/Microsoft.VisualStudio.TestTools.
Read more >
Introduction to Unit Testing with: MS tests, NUnit and Fluent ...
This article will show you the basic of using MS Unit Test ,NUnit & Fluent Assertions. I'm not intending to cover everything, but...
Read more >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found