Git Product home page Git Product logo

vssdktestfx's Introduction

Visual Studio SDK Test Framework

Build Status Join the chat at https://gitter.im/Microsoft/extendvs

Microsoft.VisualStudio.Sdk.TestFramework

NuGet package

The VS SDK Test Framework is a library for your unit tests that exercise VS code to use so that certain core VS functionality works outside the VS process so your unit tests can function. For example, ThreadHelper and obtaining global services from the static ServiceProvider tend to fail in unit tests without this library installed.

Learn more about this package.

Microsoft.VisualStudio.Sdk.TestFramework.Xunit

NuGet package

This package contains functionality applicable when using Xunit as your test framework.

Learn more about this package.

Contributing

This project has adopted the Microsoft Open Source Code of Conduct.

See our contributing doc for more info.

vssdktestfx's People

Contributors

aarnott avatar amadeusw avatar crmann1 avatar dependabot[bot] avatar eilon avatar javierdlg avatar jpwilli avatar juchom avatar kartheekp-ms avatar newrad0603 avatar reduckted avatar srdjanjovcic avatar stevebush avatar trevors20 avatar xuachen avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar  avatar  avatar  avatar

vssdktestfx's Issues

Remove Moq dependency

With the recent privacy concerns with Moq (see here, here and https://github.com/moq/moq/issues/1372), I think it would be wise to remove the dependency on Moq from the NuGet package.

I don't see why any consumers of the Microsoft.VisualStudio.Sdk.TestFramework NuGet package need to install the Moq package as well. The only place it seems to be used is in a single using declaration here:

The unit tests can continue to use Moq if you want, just as long as the published NuGet packages don't depend on it.

Class with multiple tests using MockedVSCollection and `GlobalServiceProvider` don't run all on VS

In a test project in VS, If I 'Run All' Tests from the class in VS, there are some random failing tests with the following message:

image

Message: 
    System.AggregateException : One or more errors occurred.
    ---- System.InvalidOperationException : Cannot create more than one System.Windows.Application instance in the same AppDomain.
    ---- The following constructor parameters did not have matching fixture data: GlobalServiceProvider gsp

  Stack Trace: 
    ----- Inner Stack Trace #1 (System.InvalidOperationException) -----
    Application.ctor()
    OleServiceProviderMock.MainThread()
    --- End of stack trace from previous location where exception was thrown ---
    TaskAwaiter.ThrowForNonSuccess(Task task)
    TaskAwaiter.HandleNonSuccessAndDebuggerNotification(Task task)
    OleServiceProviderMock.ctor()
    GlobalServiceProvider.ctor()
    ----- Inner Stack Trace #2 (Xunit.Sdk.TestClassException) -----

Code

Test class

using Microsoft.VisualStudio.Sdk.TestFramework;
using Xunit;

namespace LibForVsSdk.Tests
{
    [Collection("LibForVsSdk.Tests.Test")]
    public class UnitTest1
    {
        public UnitTest1(GlobalServiceProvider gsp)
        {
        }

        [Fact]
        public void TestFalse()
        {
            Assert.False(false);
        }

        [Fact]
        public void TestTrue()
        {
            Assert.True(true);
        }

        [Theory]
        [InlineData(1)]
        [InlineData(2)]
        [InlineData(3)]
        public void Test1(int number)
        {
            Assert.True(number < 10);
        }
    }
}

Collection definition

using Microsoft.VisualStudio.Sdk.TestFramework;
using Xunit;

namespace LibForVsSdk.Tests
{
    [CollectionDefinition("LibForVsSdk.Tests.Test")]
    public class CollectionDef : ICollectionFixture<GlobalServiceProvider>
    {
    }
}

Test Project file

<Project Sdk="Microsoft.NET.Sdk">

  <PropertyGroup>
    <TargetFramework>net472</TargetFramework>
    <Nullable>enable</Nullable>
	  <LangVersion>latest</LangVersion>
    <IsPackable>false</IsPackable>
  </PropertyGroup>

  <ItemGroup>
	  <PackageReference Include="Microsoft.VisualStudio.Sdk.TestFramework" Version="17.0.15" />
	  <PackageReference Include="Microsoft.NET.Test.Sdk" Version="16.11.0" />
    <PackageReference Include="xunit" Version="2.4.1" />
    <PackageReference Include="xunit.runner.visualstudio" Version="2.4.3">
      <IncludeAssets>runtime; build; native; contentfiles; analyzers; buildtransitive</IncludeAssets>
      <PrivateAssets>all</PrivateAssets>
    </PackageReference>
    <PackageReference Include="coverlet.collector" Version="3.1.0">
      <IncludeAssets>runtime; build; native; contentfiles; analyzers; buildtransitive</IncludeAssets>
      <PrivateAssets>all</PrivateAssets>
    </PackageReference>
  </ItemGroup>

</Project>

Am I doing something wrong?

Installation issue

Hello 👋

I'm trying to install it via NuGet. Trying to install Microsoft.VisualStudio.Sdk.TestFramework. But getting this error

Error NU1101 Unable to find package Microsoft.Internal.VisualStudio.Interop. No packages exist with this id in source(s): Microsoft Visual Studio Offline Packages, nuget.org

Also tried to check it on nuget.org but same issue

Screenshot 2022-05-25 at 13 53 42

Screenshot 2022-05-25 at 13 53 29

Maybe I'm doing something wrong? Could someone please help?

Best regards,
Alex

Does this support NUnit?

Does this support NUnit?
I have many unit test cases written in NUnit. Migration them seems difficult.

Release Version that Works with Visual Studio 2022?

Would it be possible, please, if you've got a moment, now Visual Studio 2022 is out, to help us VSIX devs and release a built version of the head of the code to NuGet?

I seem to need it for testing a VS2022 VSIX that references v17 of the SDK. If there's a workaround let me know please. I have built my own version and it works, but I don't really want to publish that separately on NuGet.

Can't install https://www.nuget.org/packages/Microsoft.VisualStudio.Sdk.TestFramework

I try to install this package . However, it always reports
`
Restoring packages for C:\Users\xxxx\source\repos\ImageOptimizer\Test\ImageOptimizer.Test\ImageOptimizer.Test.csproj...
GET https://api.nuget.org/v3-flatcontainer/microsoft.internal.visualstudio.interop/index.json
NotFound https://api.nuget.org/v3-flatcontainer/microsoft.internal.visualstudio.interop/index.json 1085ms

NU1101: Unable to find package Microsoft.Internal.VisualStudio.Interop. No packages exist with this id in source(s): Microsoft Visual Studio Offline Packages, nuget.org

Package restore failed. Rolling back package changes for 'ImageOptimizer.Test'.

Time Elapsed: 00:00:01.6479626
`

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.