Git Product home page Git Product logo

xunittestcodesnippets's Introduction

xUnit Test Code Snippets

Summary

This is "code snippets" for Microsoft Visual Studio 2012 or higher.

If you use these "code snippets", you can save time to coding/typing to create unit test code based on xUnit framework.

introduce movie

How to install

  1. Download "xUnitTestCodeSnippets... .vsix" (Microsoft Visual Studio Extension) file from "Visual Studio Gallery" site.
    URL: https://visualstudiogallery.msdn.microsoft.com/032cd260-d4cd-4849-adff-648ea9a28265
  2. Open (double click on Explorer) the downloaded "xUnitTestCodeSnippets... .vsix" file.
  3. Then, "VSIX Installer" was launched. Please click "Install".

How to use

Insert xUnit Fact

On C# source code in Visual Studio, you can insert xUnit Fact method by following key typing.

  • xtestm [Tab]
    or
  • fact [Tab]

Then, this snippet expanded following C# code.

[Fact]
public void MyTestMethod()
{
    throw new NotImplementedException();
}

with Display Name

  • dfact [Tab]
[Fact(DisplayName = "")]
public void MyTestMethod()
{
    throw new NotImplementedException();
}

Insert xUnit Theory

And you can also insert xUnit Theory method.
if you type following keys,

  • theory [Tab]

Then, this snippet expanded following C# code.

[Theory]
public void MyTheory()
{
    throw new NotImplementedException();
}

with Display Name

  • dtheory [Tab]
[Theory(DisplayName = "")]
public void MyTheory()
{
    throw new NotImplementedException();
}

Insert xUnit Test Class

And you can also insert xUnit test class.
if you type following keys,

  • xtestc [Tab]

Then, this snippet expanded following C# code.

public class MyTestClass
{
    [Fact]
    public void MyTestFact()
    {
        throw new NotImplementedException();
    }
}

and, "async" versions

  • afact
[Fact]
public async Task MyTestFact()
{
    throw new NotImplementedException();
}
  • dafact
[Fact(DisplayName = "")]
public async Task MyTestFact()
{
    throw new NotImplementedException();
}
  • atheory
[Theory]
public async Task MyTheory()
{
    throw new NotImplementedException();
}
  • datheory
[Theory(DisplayName = "")]
public async Task MyTheory()
{
    throw new NotImplementedException();
}

Insert xUnit Test Data Class or Member

  • xcdata
public class MyTestDataClass : IEnumerable<object[]>
{
    public IEnumerator<object[]> GetEnumerator()
    {
        yield return new object[] { };
    }

    IEnumerator IEnumerable.GetEnumerator() => GetEnumerator();
}
  • xmdata
public static IEnumerable<object[]> MyTestData => new object[][] {
    new object[]{ },
};

Release Note

  • v.1.6.0
    • Snippets for test data class and member are added (xcdata, xmdata).
  • v.1.5.1.2
    • Fix: Removed the unused "NET Framework 4 targeting pack" requirement from the manifest.
  • v.1.5.1.1
    • Fix: required name spaces are missing.
  • v.1.5.0
    • Throw NotImplementedException by default.
  • v.1.4.1
    • Fix: Cannot install on latest VS 2019 (16.1)
  • v.1.4.0
    • Add suuport for Visual Studio 2019.
    • Snippets with "DisplayName" are added (dfact, dafact, dtheory, datheory).
  • v.1.3.0
    • Add afact and atheory snippets to insert "async Task ..." methods.
  • v.1.2.0
    • Add theory and xtestc snippets.
  • v.1.1.0
    • Add fact snippet.
  • v.1.0.0
    • 1st release, it contains xtestm snippet.

License

GNU GPL v.3

xunittestcodesnippets's People

Contributors

jsakamoto avatar nbarbettini avatar tiesmaster avatar

Stargazers

NAKIGOE.ORG avatar Junichi Hashimoto avatar Rune Moskvil Lyngås avatar Lawrence LCI avatar  avatar Allan Targino avatar Sam B avatar Matthew Robertson avatar Maicon Heck avatar Jorge Morales avatar Mateus Viegas avatar Abubakr avatar Jacob avatar FroggieFrog avatar rim avatar Mamoru Komuro avatar Cesar SJ avatar Peterson Salamat avatar Jamie Webb avatar Yoshifumi Kawai avatar Nick Chamberlain avatar Stefan Ossendorf avatar  avatar Oleg Sych avatar

Watchers

 avatar James Cloos avatar  avatar  avatar

xunittestcodesnippets's Issues

Cannot install on latest VS 2019 (16.1)

Should VS 2019 Community be blocked? I'm getting an error installing it on this SKU. Will dig into this more tonight, if it's a problem on my side, but already wanted to start the discussion on it.

image

.NET Framework 4 targeting pack requirement

Why does the extension.vsixmanifest require the .NET 4 framework targeting pack? I use Visual Studio 2019 version 16.9.0 with the .NET Core cross-platform development workload installed, which already includes targeting packs for .NET Framework versions 4.5 through 4.7.2. Can this pre-requisite be removed?

  <Prerequisites>
    <Prerequisite Version="[11.0,16.0]" Id="Microsoft.Net.Component.4.TargetingPack" DisplayName=".NET Framework 4 targeting pack" />
  </Prerequisites>

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.