-
Notifications
You must be signed in to change notification settings - Fork 651
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
Better tags for spec level includes/excludes #1820
Comments
To give you some context let me describe our use-case first. As many other projects we have unit and integration tests. We would like to be able to run only one set of them. Right now we are using naming convention *Test for uni tests and *IT for integration and maven surefire plugin to run unit tests while maven failsafe plugin to run integration tests. I expect us to define more test types in the future and classify some as "slow" to avoid running them too frequently. In order to save time/CPU we'd like to avoid instantiating specs that are not of the type that was requested to run. I understand that in order to determine all tags associated with the test we need to instantiate the spec. What would work in our case is to have distinction between test type and test tag, for example:
and then |
Your use case is the perfect example of what I was trying to convey. Although rather than introduce two types of tags/things, I think just having a different annotation may be easier, because then it expands out to any use case. For example @jschneidereit uses a different tag per team. @RequiresTag(UnitTest) // tag must be present to be instantiated
class MyTest1 : FunSpec({
test("a").config(tag = FlakyTest) { }
test("b").config(tag = SlowTest) { }
}
@Tags(FooTag) // a tag that is simply added to the other tags of the tests
class MyTest2 : FunSpec({
test("c").config(tag = FlakyTest) { }
test("d").config(tag = SlowTest) { }
} MyTest1 will now only be instantiated when kotest.tags explicitly includes UnitTest. So under the following behaviors. kotest.tags=UnitTest => a,b (but MyTest2 is instantiated to search inside) The name of this annotation could be something other than RequiresTag of course. And Tags could be deprecated and replaced with another tag that is more clear, such as InheritTags or TestTags or something. ^^ @SergKhram This is what you are wanting from #1823 |
@sksamuel How it can work? If you write |
This issue has been automatically marked as stale because it has not had recent activity. It will be closed if no further activity occurs. Thank you for your contributions. |
This issue has been automatically marked as stale because it has not had recent activity. It will be closed if no further activity occurs. Thank you for your contributions. |
The current @tags on a spec is powerful but can be confusing. A spec annotated with @tags("Foo") will not necessarily be excluded if you run with kotest.tags=Bar because root level tests may be annotated with Bar and so it must instantiate the spec to check. Only if a tag is explicitly excluded does the @tags on a spec help.
This ticket is to:
The text was updated successfully, but these errors were encountered: