For ASP.NET Boilerplate
, I am trying to implement Xunit test for the project. Is there any method to provide the parameters to test methods and configure the test methods process order.
In the normal test project, I could use [InlineData("Test", 3)]
to provide the value to test methods public async void AllInOne_Test(string userName, int count)
, but for ASP.NET Boilerplate
, it did not pass the value to test method.
I also want to process TestB after TestB, how could I achieve this?
Update1:
For InlineData
issue, I could inherit TheoryAttribute
like below:
public sealed class MultiTenantTheoryAttribute : TheoryAttribute
{
public MultiTenantTheoryAttribute()
{
if (!CloudConsts.MultiTenancyEnabled)
{
Skip = "MultiTenancy is disabled.";
}
}
}
And then, use it like below:
[MultiTenantTheory]
[InlineData("Test_CreateCoupon")]
public async Task CreateCoupon_Test(string title)
{
//....
}
But, I still have an issue with test method processing order.
[MultiTenantTheory]
[InlineData("Test_CreateCoupon")]
public async Task CreateCoupon_Test(string title)
{
//...
}
[MultiTenantTheory]
[InlineData("Test_CreateCoupon", "Test_UpdateCoupon")]
public async Task UpdateCoupon_Test(string oldTitle, string updateTitle)
{
//。。。
}
In my tests, I have CreateCoupon_Test
and UpdateCoupon_Test
, I want to exec CreateCoupon_Test
, then UpdateCoupon_Test
when I run all tests. But, currently, its order is random, and I got UpdateCoupon_Test
run before CreateCoupon_Test
, then my tests failed, since I update the record which has not been created.