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

Replacement for @Rule in JUnit5 #57

Open
hazemkmammu opened this issue Jul 13, 2020 · 4 comments
Open

Replacement for @Rule in JUnit5 #57

hazemkmammu opened this issue Jul 13, 2020 · 4 comments

Comments

@hazemkmammu
Copy link

hazemkmammu commented Jul 13, 2020

Please provide hints on using the library with JUnit5. JUnit5 no longer supports the @Rule annotation and it is replaced by Extension. I think If we can do the initialization part directly using the library API from @BeforeAll, we can replace what @Rule essentially does.

@bjansen
Copy link

bjansen commented Oct 28, 2020

I have a working PoC that looks like this:

import org.junit.jupiter.api.Test;
import org.junit.jupiter.api.extension.RegisterExtension;
import org.zapodot.junit.ldap.junit5.EmbeddedLdapExtension;
import org.zapodot.junit.ldap.junit5.EmbeddedLdapExtensionBuilder;

class JUnit5Test {

    @RegisterExtension
    static EmbeddedLdapExtension ldapServer = EmbeddedLdapExtensionBuilder.newInstance()
            .usingDomainDsn("O=foo,O=bar,O=fr")
            .withSchema("custom.ldif")
            .importingLdifs("annuaire.ldif")
            .usingBindDSN("...")
            .usingBindCredentials("...")
            .build();

    @Test
    void hello() {
        System.out.println(ldapServer.embeddedServerPort());
    }
}

A big chunk of code was copy/pasted, but most of it it not directly related to JUnit, so I think I'll extract it as common abstract classes.

The extension would have the same API as the JUnit 4 rule, and could be used on static (@BeforeAll/@AfterAll) or instance (@BeforeEach/@AfterEach) fields.

bjansen added a commit to bjansen/embedded-ldap-junit that referenced this issue Oct 28, 2020
bjansen added a commit to bjansen/embedded-ldap-junit that referenced this issue Oct 28, 2020
bjansen added a commit to bjansen/embedded-ldap-junit that referenced this issue Oct 28, 2020
bjansen added a commit to bjansen/embedded-ldap-junit that referenced this issue Oct 28, 2020
@bjansen
Copy link

bjansen commented Oct 28, 2020

See PR #67

@fabiencelier
Copy link

+1, that would be awesome

@Umit-Soylu
Copy link

+1

bjansen added a commit to bjansen/embedded-ldap-junit that referenced this issue Dec 26, 2022
guusdk added a commit to guusdk/Openfire that referenced this issue Jun 21, 2023
Most unit tests are refactored to use JUnit 5 instead of 4.

Notable exceptions:
- FlattenNestedGroupsTest, which uses org.zapodot:embedded-ldap-junit which currently is based on JUnit 4 (JUnit 5 support being tracked in zapodot/embedded-ldap-junit#57 )
- DBUnit-based tests
guusdk added a commit to guusdk/Openfire that referenced this issue Jun 21, 2023
Most unit tests are refactored to use JUnit 5 instead of 4.

Notable exceptions:
- FlattenNestedGroupsTest, which uses org.zapodot:embedded-ldap-junit which currently is based on JUnit 4 (JUnit 5 support being tracked in zapodot/embedded-ldap-junit#57 )
- DBUnit-based tests
guusdk added a commit to guusdk/Openfire that referenced this issue Jun 22, 2023
Most unit tests are refactored to use JUnit 5 instead of 4.

Notable exceptions:
- FlattenNestedGroupsTest, which uses org.zapodot:embedded-ldap-junit which currently is based on JUnit 4 (JUnit 5 support being tracked in zapodot/embedded-ldap-junit#57 )
- DBUnit-based tests
guusdk added a commit to igniterealtime/Openfire that referenced this issue Jun 26, 2023
Most unit tests are refactored to use JUnit 5 instead of 4.

Notable exceptions:
- FlattenNestedGroupsTest, which uses org.zapodot:embedded-ldap-junit which currently is based on JUnit 4 (JUnit 5 support being tracked in zapodot/embedded-ldap-junit#57 )
- DBUnit-based tests
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

4 participants