0

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.

Vivek Nuna
  • 25,472
  • 25
  • 109
  • 197
Edward
  • 28,296
  • 11
  • 76
  • 121
  • Provide more context. Include a [mcve] that can be used to reproduce the problem. Right now it is unclear what you are asking. – Nkosi Apr 12 '18 at 16:28
  • I shared more details, please check whether you need any more information – Edward Apr 12 '18 at 16:44
  • Unit Tests should ideally be isolated. That said, take a look at this https://stackoverflow.com/a/34876963/5233410 – Nkosi Apr 12 '18 at 17:41

0 Answers0