This may be related to question: Dynamic playlists of unit tests in visual studio.
I want to be able to have one or more playlists of tests and not have not add every single new test to a certain playlist.
I currently have one playlist containing all my unit tests, but in the future I want to have a playlist consisting of automated integration tests, which should be run before committing to TFS but not every time the application builds.
Is there a way to do this?
To create a playlist, choose one or more tests in Test Explorer. Right-click and choose Add to Playlist > New playlist. To open a playlist, choose the playlist icon in the Visual Studio toolbar and select a previously saved playlist file from the menu.
The main difference is the ability of MsTest to execute in parallel at the method level. Also, the tight integration of MsTest with Visual Studio provides advantages in both speed and robustness when compared to NUnit. As a result, I recommend MsTest.
Im not aware of the types of settings you can use in TFS, since Im not using TFS, but I know it is possible using Categories in both, NUnit and MSTest.
With NUnit, you can mark single tests or even the whole fixtures with a Category
-Attribute:
namespace NUnit.Tests
{
using System;
using NUnit.Framework;
[TestFixture]
[Category("IntegrationTest")]
public class IntegrationTests
{
// ...
}
}
or
namespace NUnit.Tests
{
using System;
using NUnit.Framework;
[TestFixture]
public class IntegrationTests
{
[Test]
[Category("IntegrationTest")]
public void AnotherIntegrationTest()
{
// ...
}
}
}
and the only run those using nunit-console.exe:
nunit-console.exe myTests.dll /include:IntegrationTest
The Solution for MSTest is very similar:
namespace MSTest.Tests
{
[TestClass]
public class IntegrationTests
{
[TestMethod]
[TestCategory("IntegrationTests")
public void AnotherIntegrationTest()
{
}
}
}
But here you have to mark all Tests with that attribute, it cannot be used to decorate the whole class.
Then, like with NUnit, only execute those tests in the IntegrationTests-category:
Using VSTest.Console.exe
Vstest.console.exe myTests.dll /TestCaseFilter:TestCategory=IntegrationTests
Using MSTest.exe
mstest /testcontainer:myTests.dll /category:"IntegrationTests"
You can also execute certain Test-Categories using the TestExplorer of VS.
(source: s-msft.com)
As seen in the above image, you can select a category in the top left corner of the TestExplorer. Select Trait and execute only the catgegory that you want to.
See MSDN for more Information.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With