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.

AssertIsTrue: Simplify Assertion does not offer automatic fix to apply

See original GitHub issue

Description

AssertIsTrue: Simplify Assertion does not offer automatic fix to apply.

Complete minimal example reproducing the issue

This gets a suggestion but there is no fix shown to apply in VS.

using Microsoft.VisualStudio.TestTools.UnitTesting;

namespace TestProject1
{
    [TestClass]
    public class UnitTest1
    {
        [TestMethod]
        public void TestMethod1()
        {
            Assert.IsTrue(true);
        }
    }
}

image

Expected behavior:

Fix suggestion should be shown.

Actual behavior:

Fix suggestion is not shown.

Versions

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

Issue Analytics

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

github_iconTop GitHub Comments

1reaction
robertMSFTEcommented, Apr 6, 2022

@Meir017 This was just an example. The issue is that in general the fix never seems to be shown for this rule.

Example without a constant:

using Microsoft.VisualStudio.TestTools.UnitTesting;

namespace TestProject1
{
    [TestClass]
    public class UnitTest1
    {
        [TestMethod]
        public void TestMethod1()
        {
            Assert.IsTrue(ComputeSomething());
        }

        private bool ComputeSomething()
        {
            return true;
        }
    }
}
0reactions
robertMSFTEcommented, Jun 19, 2023

@Meir017 The scenario still reproduces on 0.20.0 - aka. there is no fix suggestion.

Read more comments on GitHub >

github_iconTop Results From Across the Web

Java static code analysis: JUnit assertTrue/assertFalse ...
Testing equality or nullness with JUnit's assertTrue() or assertFalse() should be simplified to the corresponding dedicated assertion.
Read more >
Unit Testing and Coding: Why Testable Code Matters
In this article, I will show that unit testing itself is quite easy; the real problems that complicate unit testing, and introduce expensive...
Read more >
The problem with Assert.IsTrue - Aaron Powell
Do you know what's wrong with this test? I'll give you a clue, the developer use Assert.IsTrue and by doing so they've made...
Read more >
c# - MS Test assertion checking
There are many ways to do so: Debugging. Try debugging the Test instead of just running it. This will cause an exception beeing...
Read more >
Stop requiring only one assertion per unit test
Assertion Roulette doesn't mean that multiple assertions are bad. When I coach teams or individual developers in test-driven development ...
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