Coder Social home page Coder Social logo

mstest-analyzer's Introduction

Appveyor Build Appveyor Tests Code Coverage GitHub Licence

Codacy CodeFactor

mstest-analyzer

A .Net analyzer that helps to avoid basic mistakes with the MSTest framework

Installation

nuget install mstest-analyzer

Implemented checks

Code Description
MT1001 Public class should have a test attribute
MT1002 Internal class should not have a test attribute
MT1003 Public method should have a test attribute
MT1004 Non-Public method should not have a test attribute

mstest-analyzer's People

Contributors

superfaz avatar

Stargazers

 avatar  avatar  avatar

Watchers

 avatar  avatar  avatar

mstest-analyzer's Issues

MT1003 auto-fix doesn't work as expected

How to reproduce

Create a test class with documentation like:

using Microsoft.VisualStudio.TestTools.UnitTesting;

namespace MyTest
{
    /// <summary>
    /// Tests the <see cref="MyClass"/> class.
    /// </summary>
    [TestClass]
    public class MyClassTest
    {
        /// <summary>
        /// Tests the <see cref="MyClass.MyClass"/> constructor.
        /// </summary>
        public void Constructor()
        {
        }
    }
}

Use the auto-fix feature for MT1003, result is:

using Microsoft.VisualStudio.TestTools.UnitTesting;
using Microsoft.VisualStudio.TestTools.UnitTesting;

namespace MyTest
{
    /// <summary>
    /// Tests the <see cref="MyClass"/> class.
    /// </summary>
    [TestClass]
    public class MyClassTest
    {
        [TestMethod]
          /// <summary>
                              /// Tests the <see cref="MyClass.MyClass"/> constructor.
                              /// </summary>
        public void Constructor()
        {
        }
    }
}

Expected result

  • The using reference should not be doubled
  • The [TestMethod] should be between the comment and the method signature
  • The method comment should remain untouched

The result of the auto-fix should be:

using Microsoft.VisualStudio.TestTools.UnitTesting;

namespace MyTest
{
    /// <summary>
    /// Tests the <see cref="MyClass"/> class.
    /// </summary>
    [TestClass]
    public class MyClassTest
    {
        /// <summary>
        /// Tests the <see cref="MyClass.MyClass"/> constructor.
        /// </summary>
        [TestMethod]
        public void Constructor()
        {
        }
    }
}

Extra dependencies

The published nuget package has dependencies on FxCopAnalyzers and StyleCop.Analyzers.

Without having read your code I imagine that those should be private assets.

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.