8000 Replace @BeforeEach guard with @TestSetup in ClientApiV2AuthorizationTest · Issue #48362 · keycloak/keycloak · GitHub
[go: up one dir, main page]

Skip to content

Replace @BeforeEach guard with @TestSetup in ClientApiV2AuthorizationTest #48362

Description

@Pepo48

Description

ClientApiV2AuthorizationTest uses a manual guard flag pattern to avoid repeated admin client setup across 13 test methods:

@BeforeEach
public void setupClients() {
    if (adminClients.isEmpty()) {
        for (String currentUser : CURRENT_USERS) {
            adminClients.put(currentUser, createAdminClient(currentUser));
        }
    }
}

The new test framework already provides @testsetup for exactly this purpose - it runs once per test class, after field injection, so injected fields like @InjectAdminClientFactory are available.

We should remove the manual workaround and use the framework's mechanism instead.
I did some test measurements as well - setup still runs exactly once, all 13 tests pass with identical timing. So no behaviour change compared to the workaround.

Activity

  1. self-assigned this
    on Apr 22, 2026
  2. added theissue type on Apr 22, 2026
  3. added a commit that references this issue on Apr 22, 2026
    86e4f54
  4. added a commit that references this issue on Jul 20, 2026
    b8c1051
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

Type

Fields

No fields configured for task.

Projects

No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions

    0