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

Question: Is it still possible in new Serenity versions to run JUnit 4 tests via Maven using Serenity tag annotations (i.e., -Dtags="tag1") and have them included in the report? #3607

Open
bensashi opened this issue Jan 28, 2025 · 1 comment
Labels

Comments

@bensashi
Copy link

We are in the process of migrating a large test project from an older Serenity version (3.6.x) and Java 8 to a much more recent Serenity release (4.2.8) and Java 21.

The relevant details about our tests:

  1. Written against JUnit 4.
  2. Using SerenityParameterizedRunner.
  3. Data-driven using Serenity's @UseTestDataFrom annotation.
  4. Tagged using Serenity's @WithTag, @WithTags, and @WithTagValuesOf annotations.

I have no compelling reason at the moment to move the tests to JUnit 5 if we can avoid it. Our current method of executing a specific test or group of tests and generating the report is via Maven using the -Dtags parameter.

I am still able to get specific tests to run this way by passing a matching tag with -Dtags, but am finding that when Serenity's report is subsequently generated that the test is not included. I believe this behavior is a known issue and already documented in #3308. There is a similar issue noted at #2976 indicating that tests can not be run by targeting tags that were using Serenity's tag annotations.

The only solution that I am able to glean from these other issues is to migrate tests to JUnit 5, replace Serenity's tag annotations with the JUnit equivalents, and target tags using -Dgroups. From some brief analysis, I believe in order to do this I'd also need to switching from using the @UseTestDataFrom Serenity annotation to the @CsvFileSource JUnit annotation. I have not determined what additional changes (if any) would be required along with the annotation change in order to ensure that the actual data from the CSV gets parsed and is accessible as it would with the Serenity annotation.

I am guessing the reality is that we just need to do the work of moving everything to JUnit 5, but am hoping someone else out there might be in a similar situation and know of a workaround I have not discovered yet. Any help is greatly appreciated.

@wakaleo
Copy link
Member

wakaleo commented Jan 30, 2025

SerenityParameterizedRunner isn't supported in JUnit 5 as it has it's own parameterised runners, so my recommendation is to move to JUnit 5 tests and use the native JUnit 5 tagging and filtering.

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

No branches or pull requests

2 participants