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

Problem using @DisabledIfSystemProperty #2969

Open
ztztzt8888 opened this issue Nov 14, 2022 · 3 comments
Open

Problem using @DisabledIfSystemProperty #2969

ztztzt8888 opened this issue Nov 14, 2022 · 3 comments

Comments

@ztztzt8888
Copy link

We have existing API tests using annotations such as

@DisabledIfSystemProperty(named = "environment", matches = "prod")

When we add serenity to the dependency (latest version 3.4.2) the unrelated tests with the tags above start to skip regardless of the environment it was running in. So basically they all stopped running in our nightly build for all environment.

The SkippedTestException was thrown at net.serenitybdd.junit5.SerenityJUnit5Extension.lambda$afterEach$1(SerenityJUnit5Extension.java:74)

@ztztzt8888
Copy link
Author

ztztzt8888 commented Nov 14, 2022

It was thrown by this method

>  @Override
>     public void afterEach(ExtensionContext context) {
>         if (!StepEventBus.getEventBus().isBaseStepListenerRegistered()) {
>             LOGGER.warn("NO BASE STEP LISTENER FOUND IN THREAD " + Thread.currentThread());
>         }
>         TestOutcome outcome = StepEventBus.getEventBus().getBaseStepListener().getCurrentTestOutcome();
>         String methodName = outcome.getQualifiedMethodName();
>         context.getTestMethod().ifPresent(
>                 method -> {
>                     // Make sure it's the right test - not sure when this gets called in parallel testing.
>                     if (method.getName().equals(methodName)) {
>                         // Failing test
>                         if (outcome.getTestFailureCause() != null) {
>                             throw outcome.getTestFailureCause().asRuntimeException();
>                         } else if (outcome.isPending()) {
>                             throw new PendingTestException(context.getDisplayName());
>                         } else if (outcome.isSkipped()) {
>                             throw new SkippedTestException(context.getDisplayName());
>                         }
>                     }
>                 }
>         );
>     }

@wakaleo
Copy link
Member

wakaleo commented Nov 15, 2022

Well spotted. Can you propose a PR?

@wakaleo
Copy link
Member

wakaleo commented Nov 27, 2022

Can you provide a sample project to reproduce this?

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