Skip to content

Invoke @BeforeAll method for a dry run #2989

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

Open
wazzeps opened this issue Apr 21, 2025 · 3 comments
Open

Invoke @BeforeAll method for a dry run #2989

wazzeps opened this issue Apr 21, 2025 · 3 comments

Comments

@wazzeps
Copy link

wazzeps commented Apr 21, 2025

🤔 What's the problem you're trying to solve?

Currently, if the dry run property is set to true outside a method annotated with @BeforeAll, this method is not invoked.

Therefore, there is no possibility to dynamically filter scenarios in the code.

A dry run without filtering does not take much time, but it affects the overall statistics of automated tests, since third-party libraries cannot distinguish the result of a normal run from a dry one.

✨ What's your proposed solution?

Add a configuration property to enable/disable the @BeforeAll (and @ AfterAll ?) method invocation.

⛏ Have you considered any alternatives or workarounds?

For now we can set the dry run property to true in the @BeforeAll method and it will be invoked.

📚 Any additional context?

No response

@wazzeps wazzeps closed this as not planned Won't fix, can't repro, duplicate, stale Apr 21, 2025
@wazzeps wazzeps reopened this Apr 21, 2025
@wazzeps wazzeps changed the title Dry run with filtering Invoke @BeforeAll method for a dry run Apr 21, 2025
@mpkorstanje
Copy link
Contributor

mpkorstanje commented Apr 21, 2025

Could you clarify what you mean by dynamic filtering? I don't believe you that this is currently possible at all.

@wazzeps
Copy link
Author

wazzeps commented Apr 22, 2025

Calculating the filtering expression at runtime. At least it works with tags.

@BeforeAll
public static void beforeAll() {
    System.setProperty(Constants.EXECUTION_DRY_RUN_PROPERTY_NAME, String.valueOf(true));
    System.setProperty(Constants.FILTER_TAGS_PROPERTY_NAME, calculateTagsExpression());
}

But in case the dry run property is set to true, for example, in the Gradle task, this will not work, because the @BeforeAll method will not be invoked.

@mpkorstanje
Copy link
Contributor

mpkorstanje commented Apr 22, 2025

As you are using Gradle, and presumably the JUnit Platform, have you considered using the JUnit 5 tag expressions (slightly different from Cucumbers) and calculating these in Gradle?

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

2 participants