asherber / xunit.priority Goto Github PK
View Code? Open in Web Editor NEWProvides an ITestCaseOrderer that allows you to control the order of execution of Xunit tests within a class.
License: Apache License 2.0
Provides an ITestCaseOrderer that allows you to control the order of execution of Xunit tests within a class.
License: Apache License 2.0
It's very easy to have one test that run before everyone else by adding a Priority attribute with everyone else left un-attributed
however, it is impossible to mark one test to run at the end without attributing all others,
the code defaults the Priority to int.MaxValue which leaves no room to append anything later than default, suggest find a mid-value as a default to give flexibility
Thanks
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);
}
}
in my tests, xunit ignored the priority attribute.. might be my test case, or an xunit change.. might be worth checking
Hi, how can I use it in theory tests? I means that use it per InlineData attribute.
Thanks a lot for your library!
I have a single test with some assertions I want to run after all other tests are finished, but I think the only way to do that now is to apply the DefaultPriority to all test classes.
If the default priority was always 0 I would only have to create a single test with priority 1 for this.
Would that be something you'd accept as change? Or maybe allow the DefaultPriority to be set on assembly level?
For async test methods ordering doesn't work? It is required to disable parallelization for that. Is there a way to achieve that?
I have a small automation app scenario where the bulk of my integration tests are all creating an artifact, validating the artifact and then that artifact gets used with a subsequent test. I realize that is horrible, but it is what makes sense for my situation. So, you can consider every class and every test within the classes prioritized.
Unfortunately, Xunit.Priority doesn't seem up to that level of rigid sequencing. It appears to only prioritize the tests within a class, not every test in the run. Know of a simple way of forcing X.P. to run tests in exactly the order they are specified and not allow parallel testing across classes?
I am probably going to ditch X.P. on this project and follow the below article, but it would be real nice if there was a simple XUnit based nuget package out there for accomplishing this. If you are interested in this enhancement request, note that the ideal solution would involve me being able to specify what can/cannot be parallelized.
https://hamidmosalla.com/2018/08/16/xunit-control-the-test-execution-order/
A declarative, efficient, and flexible JavaScript library for building user interfaces.
๐ Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
An Open Source Machine Learning Framework for Everyone
The Web framework for perfectionists with deadlines.
A PHP framework for web artisans
Bring data to life with SVG, Canvas and HTML. ๐๐๐
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
Some thing interesting about web. New door for the world.
A server is a program made to process requests and deliver data to clients.
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
Some thing interesting about visualization, use data art
Some thing interesting about game, make everyone happy.
We are working to build community through open source technology. NB: members must have two-factor auth.
Open source projects and samples from Microsoft.
Google โค๏ธ Open Source for everyone.
Alibaba Open Source for everyone
Data-Driven Documents codes.
China tencent open source team.