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

Adding Trait to CollectionDefinition #799

Closed
xmedeko opened this issue Mar 15, 2016 · 6 comments
Closed

Adding Trait to CollectionDefinition #799

xmedeko opened this issue Mar 15, 2016 · 6 comments

Comments

@xmedeko
Copy link

xmedeko commented Mar 15, 2016

In xUnit and Visual Studio, I would like to group tests marked with the [Collection("DB")] attribute in the Test Explorer. I can group test by the [Trait("Collection", "DB")] attribute only. Is there any way how to assign a specific Trait to all tests with the [Collection("DB")] attribute?
(I have also asked on SO).

@jchannon
Copy link

jchannon commented Apr 15, 2016

I need something similar, I have some tests in my project split into those that have state and those that don't. These are marked with the Collection attribute. It would be nice to run them such as xunit.console.exe My.dll -collection mycollection and therefore only runs the tests that require state

@zwcloud
Copy link

zwcloud commented Nov 15, 2016

One implementation I found: http://mac-blog.org.ua/xunit-category-trait/

@xmedeko
Copy link
Author

xmedeko commented Nov 15, 2016

@zwcloud it's a bit simplification of the problem, but does not solve that. Now, I have to mark a method

[Trait("Collection", "DB")] 
[Collection("DB")]

With your solution, I would do

[Category("DB")] 
[Collection("DB")]

But I would like to use [Collection("DB")] only and have it automatically added to a Trait.

@bradwilson
Copy link
Member

Closed for age.

@TheConstructor
Copy link

@bradwilson this is still not possible, right? To me it would also be ok, to just have the collection-name added as collection trait

@bradwilson
Copy link
Member

@TheConstructor That is correct, this is not a feature.

If someone wanted to create a PR for this, I wouldn't want to add an automatic trait for every collection, because you potentially run afoul of someone already using a trait named Collection (or whatever name you chose), and some people wouldn't want the additional noise of the extra trait.

I would be willing to accept a PR that adds traits to tests based on putting trait attributes on the collection definition class itself. That would allow people to add whatever traits that wanted (names and values) in a central location.

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

5 participants