Comments (3)
Follow https://github.com/microsoft/vssdktestfx/blob/main/doc/mstest.md, I successfully run all my cases with NUnit.
We may not really need to add separate attribute class. Manually adding AssemblySetup.MockServiceProvider.Reset()
to the constructor or [SetUp]
section of every test class should also work.
Add this class to your test folder.
using Microsoft.VisualStudio.Sdk.TestFramework;
using NUnit.Framework;
namespace Application.Test
{
[SetUpFixture]
public class AssemblySetup
{
internal static GlobalServiceProvider MockServiceProvider { get; private set; }
[OneTimeSetUp]
public void RunBeforeAnyTests()
{
MockServiceProvider = new GlobalServiceProvider();
}
[OneTimeTearDown]
public void RunAfterAnyTests()
{
MockServiceProvider.Dispose();
}
}
}
Create a attribute class
using System;
namespace Application.Test
{
[AttributeUsage(AttributeTargets.Class)]
public class TestWithAttribute : Attribute
{
public TestWithUnityContainerAttribute()
{
AssemblySetup.MockServiceProvider.Reset();
}
}
}
Add the attribute annotation to every test class
namespace Application
{
[TestFixture]
[TestWithAttribute]
public class AnalysisTest
{
[Test]
public void Test()
{
Assert.AreEqual(1, 1);
}
}
}
from vssdktestfx.
Not directly. But it doesn't directly support MSTest either and folks get by just fine with it. We only added Xunit-specific helpers very recently. Just review either xunit or mstest documentation and do the equivalent thing for NUnit. Once you figure it out, if you'd like to share back, I'd entertain a PR to add NUnit to our docs.
from vssdktestfx.
Thank you for sharing. Wanna send a PR that adds an nunit.md doc to the repo, @maysonchen-cs?
from vssdktestfx.
Related Issues (8)
- Nuget package not found. HOT 2
- Class with multiple tests using MockedVSCollection and `GlobalServiceProvider` don't run all on VS HOT 1
- Can't install https://www.nuget.org/packages/Microsoft.VisualStudio.Sdk.TestFramework HOT 1
- Installation issue HOT 1
- Release Version that Works with Visual Studio 2022? HOT 8
- VsTaskCompletionSource cancellation does not properly get propogated to VsTask.Result HOT 3
- 17.0 release requires additional nuget feeds
Recommend Projects
-
React
A declarative, efficient, and flexible JavaScript library for building user interfaces.
-
Vue.js
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
-
Typescript
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
-
TensorFlow
An Open Source Machine Learning Framework for Everyone
-
Django
The Web framework for perfectionists with deadlines.
-
Laravel
A PHP framework for web artisans
-
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.
-
Visualization
Some thing interesting about visualization, use data art
-
Game
Some thing interesting about game, make everyone happy.
Recommend Org
-
Facebook
We are working to build community through open source technology. NB: members must have two-factor auth.
-
Microsoft
Open source projects and samples from Microsoft.
-
Google
Google ❤️ Open Source for everyone.
-
Alibaba
Alibaba Open Source for everyone
-
D3
Data-Driven Documents codes.
-
Tencent
China tencent open source team.
from vssdktestfx.