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

Allow to supply tags via an extension #3932

Open
reda-alaoui opened this issue Aug 22, 2024 · 10 comments
Open

Allow to supply tags via an extension #3932

reda-alaoui opened this issue Aug 22, 2024 · 10 comments

Comments

@reda-alaoui
Copy link

I have a multi maven module project and CI configured to split test executions among multiple groups. To do that, I use property groups of maven-surefire-plugin. I want each test to be tagged with the name of the module it belongs to. For example, all tests of module foo should be tagged @Tag("foo").
Meta-annotations are not good enough because someone will forget to annotate a test class.

Since Extension can be registered as service loaders, it'd be nice to be able to provide the tag information from an Extension.

@MDOluka

This comment was marked as spam.

@sbrannen
Copy link
Member

@MDOluka, it appears that you are using AI to create your responses.

If so, please refrain from doing that, since it does not add value to the discussions.

@sbrannen
Copy link
Member

Hi @reda-alaoui,

Congratulations on opening your first issue for JUnit 5. 👍

Since Extension can be registered as service loaders, it'd be nice to be able to provide the tag information from an Extension.

The Extension APIs in JUnit Jupiter are applied during the "execution phase"; whereas, tags (configured via the @Tag annotation) are processing during the "discovery phase".

Consequently, a Jupiter extension cannot provide tags.

The tags sourced from @Tag are made available via TestTag instances in org.junit.platform.engine.TestDescriptor.getTags(). And those are processed in org.junit.platform.launcher.TagFilter which creates corresponding org.junit.platform.launcher.PostDiscoveryFilter instances.

Thus, it sounds like you might be able to achieve your goal via a custom PostDiscoveryFilter which filters out tests that do not "belong to the current module".

See Registering a PostDiscoveryFilter in the User Guide for details and let us know if that suits your needs.

Cheers,

Sam

@sbrannen sbrannen changed the title Allow to @Tag an extension Allow to supply tags via an extension Aug 23, 2024
@MDOluka
Copy link

MDOluka commented Aug 23, 2024

@MDOluka, it appears that you are using AI to create your responses.

If so, please refrain from doing that, since it does not add value to the discussions.

i read the Junit user guide and also do some research using a.i but not to create responses.

@reda-alaoui
Copy link
Author

Hi @sbrannen ,

Thus, it sounds like you might be able to achieve your goal via a custom PostDiscoveryFilter which filters out tests that do not "belong to the current module".

I tried to use PostDiscoveryFilter. But I didn't find a way to access the expression provided by attribute groups from maven-surefire-plugin.

My goal is not to make sure only tests of the module run. My goal is to run a full build including all modules and telling which tests should run via tags. I have projects where the same tag will be shared by 2 modules.

This comment was marked as outdated.

@reda-alaoui

This comment was marked as outdated.

@sbrannen

This comment was marked as outdated.

@sbrannen sbrannen closed this as not planned Won't fix, can't repro, duplicate, stale Sep 8, 2024
@reda-alaoui

This comment was marked as outdated.

@sbrannen

This comment was marked as outdated.

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

No branches or pull requests

4 participants