Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

DefaultPriority bug #7

Closed
sarowa36 opened this issue Aug 31, 2023 · 3 comments
Closed

DefaultPriority bug #7

sarowa36 opened this issue Aug 31, 2023 · 3 comments

Comments

@sarowa36
Copy link

Hello i have problem about your library. when i use defaultpriority attribute some method who have bigger priority than defaultpriority value its doesnt work/trigger.

 [TestCaseOrderer(PriorityOrderer.Name, PriorityOrderer.Assembly)
     ,DefaultPriority(0)]
 public class ContentControllerTests
 {
     HttpClient client { get; set; }
     static int DefaultFirstItemId { get { return 1; } }
     public ContentControllerTests()
     {
         var server = new TestServer(new WebHostBuilder().UseStartup<VideoSite.Program>());
         client = server.CreateClient();
         Environment.SetEnvironmentVariable("IsInUnitTest", "1");
     }
     [Fact, Priority(-10)]
     public async void Create()
     {
         var data = new ContentViewModel();
         ByteArrayContent img = CreateImageContentForTest.Create();
         var postData = ObjectToMultipartFormDataConverter.Convert(data);
         postData.Add(img, "File", "test.png");

         var res = await client.PostAsync("api/content/create", postData);
         Assert.Equal(HttpStatusCode.OK, res.StatusCode);
     }
     [Fact]
     public async void GetListWithOutParameter()
     {
         var res =await client.GetAsync("api/Content/GetList");
         var values =  JsonConvert.DeserializeObject<List<Content>>(await res.Content.ReadAsStringAsync());

         res.EnsureSuccessStatusCode();

         Assert.Equal(HttpStatusCode.OK,res.StatusCode);
         Assert.Equal(1, values.Count);
     }
     [Fact,Priority(10)]
     public async void Delete()
     {
         var res = await client.GetAsync("api/content/delete/" + DefaultFirstItemId);
         Assert.Equal(HttpStatusCode.OK, res.StatusCode);
     }
 }

resim
xunit version: 2.42
.net version: 7.0.4

@asherber
Copy link
Owner

Thanks for the detailed report! I'll take a look at this later today.

@asherber
Copy link
Owner

I'm not able to reproduce this. Here's the class I'm using:

[TestCaseOrderer(PriorityOrderer.Name, PriorityOrderer.Assembly)]
[DefaultPriority(0)]
public class TestClass
{
    [Fact, PriorityAttribute(10)]
    public void Foo()
    {
        Console.WriteLine("third");
    }

    [Fact, PriorityAttribute(-10)]
    public void Bar()
    {
        Console.WriteLine("first");
    }
    
    [Fact]
    public void Baz()
    {
        Console.WriteLine("second");
    }
}

All three tests run for me, in the correct order. Is it possible you have some filter on your test runner that is preventing your Delete() test from running? Are you able to put together a test class that reproduces the issue that doesn't have a dependency on your server code?

@sarowa36
Copy link
Author

Oh sorry mate thats error about my spaggetti code.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants