I have unit tests in my C#
project (VisualStudio 2015
,Nunit
). I want to check methods in many different situations with different parameters, to achieve that, i used TestCases. Each test method works very slow - few seconds, and TestCases count in my projects grows.
So now testing takes some minutes. I tried to parallel these tests, by moving each test to separate TestFixture - Nunit
allows to run TestFixtures in parallel - Nunit Documentation. It slightly changed situation, but not significantly. I want to parallel tests not on the TestFixture level, but on testcases level. I don't know how to do it. I have read documentation for Nunit
, Xunit
, MBUnit
etc. and didn't found the answer.
How can i run my tests in parallel, in such way that testscases will run simultaneously? Which framework to use?
My tests example:
public static class GeneralTestCases
{
public static IEnumerable TestStoresCredentials
{
get
{
yield return new TestCaseData( ... ).SetName("incorrect password");
...
yield return new TestCaseData( ... ).SetName("incorrect login");
}
}
}
[ TestFixture ]
[ Parallelizable ]
internal class GetProducts : BaseTest
{
[ Test ]
[ TestCaseSource( typeof( GeneralTestCases ), "TestCases" ) ]
public void ReceiveProducts( TestCase case )
{
// ------------ Arrange
var service = CreateService( case.User, case.Key, ... );
// ------------ Act
var serviceResponse = service.GetProducts(case.SpecialType);
// ------------ Assert
...
serviceResponse.Message.Should().NotBeNullOrEmpty();
...
}
}
[ TestFixture ]
[ Parallelizable ]
internal class GetOrders : BaseTest
{
[ Test ]
[ TestCaseSource( typeof( GeneralTestCases ), "TestCases" ) ]
public void ReceiveOrders( TestCase case )
{
// ------------ Arrange
var service = CreateService( case.User, case.Key, ... );
// ------------ Act
var serviceResponse = service.GetOrders(case.SpecialType);
// ------------ Assert
...
serviceResponse.Message.Should().NotBeNullOrEmpty();
...
}
}
Aucun commentaire:
Enregistrer un commentaire