Open hazemkmammu opened 4 years ago
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.
See PR #67
+1, that would be awesome
+1
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.