Code Monkey home page Code Monkey logo

vsixtesting's Introduction

VsixTesting

# Join the chat at https://gitter.im/josetr/VsixTesting Build status codecov MyGet

VsixTesting allows you to easily test your Visual Studio Extensions.

Image

Getting Started

The fastest way to get started is cloning the VsixTestingSamples repo and playing with it.

git clone https://github.com/josetr/VsixTestingSamples

Create the test project

TestProject.csproj

<Project Sdk="Microsoft.NET.Sdk">
  <PropertyGroup>
    <TargetFramework>net461</TargetFramework>
    <PlatformTarget>x86</PlatformTarget>
  </PropertyGroup>

  <ItemGroup>
    <PackageReference Include="xunit" Version="2.3.1" />
    <PackageReference Include="xunit.runner.visualstudio" Version="2.3.1" />
    <PackageReference Include="VsixTesting.Xunit" Version="0.1.49-beta" /> 
    <!-- Optional package containing types used in this sample. -->    
    <PackageReference Include="VSSDK.Shell.11" Version="11.0.4" /> 
    <!-- 
      <ProjectReference Include="..\MyVsixProject\MyVsixProject.csproj" />      
      * VsixTesting contains an MSBuild target that scans all project references
         and if they generate a .vsix package, it will copy them 
         to the output folder where the test assembly is located.
      * VsixTesting will install all .vsix packages located next to the test assembly.
    -->        
  </ItemGroup>
</Project>

TestClass.cs

using Microsoft.VisualStudio.Shell;
using Microsoft.VisualStudio.Shell.Interop;
using Xunit;

namespace Tests
{  
    public class TestClass
    {
        [VsFact]
        void FactTest()
            =>  Assert.NotNull(Package.GetGlobalService(typeof(SVsWebBrowsingService)));

        [VsTheory]
        [InlineData(123)]
        void TheoryTest(int n)
        {
            Assert.NotNull(Package.GetGlobalService(typeof(SVsWebBrowsingService)));
            Assert.Equal(123, n);
        }
    }
}

Configuring how tests run

All the settings are located in ITestSettings and are implemented by 3 attributes:

  • [VsTestSettings] for classes/collections/assemblies
  • [VsFact] and [VsTheory] for methods

Intellisense should be used to read the documentation for each property that can be set.

License

This repository is licensed with the Apache, Version 2.0 license.

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.