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

improve: allow flaky tests run with specify parameters #4412

Open
wants to merge 1 commit into
base: master
Choose a base branch
from

Conversation

shoothzj
Copy link
Member

Fix #3249

Motivation

This PR addresses the issue where tests annotated with @FlakyTest were not being executed by JUnit unless they were also annotated with @test. To resolve this, we have updated our Maven Surefire plugin configuration to exclude tests tagged with flaky during regular CI runs, allowing these tests to be run separately. This adjustment ensures that all tests, including those marked as flaky, are executed as intended unless explicitly excluded. Moreover, we've planned the addition of a daily CI job and non-required CI to specifically run tests tagged as flaky, ensuring continuous monitoring and quicker identification of intermittent issues without affecting the main test pipeline. This setup also enhances the ability to run tests directly from the IDE, making it more convenient for developers to execute and debug individual tests as needed.

Signed-off-by: ZhangJian He <shoothzj@gmail.com>
Copy link
Member

@lhotari lhotari left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

ChatGPT claims that it's possible to make the custom annotation hold the @Test and @Tag annotations when there's @Retention(RetentionPolicy.RUNTIME)

package org.apache.bookkeeper.common.testing.annotations;

import java.lang.annotation.Documented;
import java.lang.annotation.Retention;
import java.lang.annotation.RetentionPolicy;
import org.junit.jupiter.api.Tag;
import org.junit.jupiter.api.Test;

/**
 * Intended for marking a test case as flaky.
 */
@Documented
@Target({ ElementType.TYPE, ElementType.METHOD })
@Retention(RetentionPolicy.RUNTIME)
@Tag("flaky")
@Test
public @interface FlakyTest {

    /**
     * Context information such as links to discussion thread, tracking issues etc.
     *
     * @return context information about this flaky test.
     */
    String value();
}

I didn't validate this. Could you please check?

@lhotari
Copy link
Member

lhotari commented Jun 14, 2024

Looks like it's in the Junit Jupiter docs too. Please see 2.1.1. Meta-Annotations and Composed Annotations.

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

Successfully merging this pull request may close these issues.

Multiple tests marked as "@FlakyTest" and de-facto not running
2 participants