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

Dynamic test support #62

Draft
wants to merge 1 commit into
base: main
Choose a base branch
from
Draft

Conversation

mk868
Copy link
Contributor

@mk868 mk868 commented Dec 15, 2024

Related: #59

I'm still not 100% convinced that this is the correct use of UriSource, so I set PR as a draft.
Some links:

I used a custom scheme xray:// to force not to use FileSource or DirectorySource - we need DefaultUriSource to not lose query data, see UriSource#from(URI) implementation.

Sample test class:

package xyz;

import static org.junit.jupiter.api.DynamicTest.dynamicTest;

import app.getxray.xray.junit.customjunitxml.XrayURI;
import java.util.List;
import org.junit.jupiter.api.DynamicTest;
import org.junit.jupiter.api.TestFactory;

class DynTest {

  @TestFactory
  List<DynamicTest> something() {
    return List.of(
        dynamicTest("test 1",
            XrayURI.builder()
                .key("ABC-100")
                .summary("Summary 1")
                .description("description 1")
                .build(this.getClass()),
            () -> {
              // ...
            }),
        dynamicTest("test 2",
            XrayURI.builder()
                .key("ABC-200")
                .summary("Summary 2")
                .build(this.getClass()),
            () -> {
              // ...
            }),
        dynamicTest("test 3",
            XrayURI.builder()
                .key("ABC-300")
                // should we pass the dynamic test's display name "test 3" as summary to the report?
                .description("description 3")
                .build(this.getClass()),
            () -> {
              // ...
            })
    );
  }

}

@mk868 mk868 marked this pull request as draft December 15, 2024 17:52
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.

1 participant