embedded-ldap-junit
embedded-ldap-junit copied to clipboard
Add support for JUnit 5 extensions (#57)
Update here: https://github.com/zapodot/embedded-ldap-junit/pull/67#issuecomment-889780610
~~Notes:~~
~~* I didn't copy/adapt the full test suite because the code I put in the abstract classes is already tested by the Rule tests. I only added tests that make sure the builder works and the Extension starts/stops the server correctly.~~
~~* I declared the junit-jupiter-api
Maven dependency as optional
to not force JUnit 5 down the throat of existing projects that use JUnit 4.~~
~~* I considered changing the junit
dependency to be optional
too, but didn't do it because that could possibly break projects that don't pull JUnit 4 explicitly when they upgrade embedded-ldap-junit
to the next version.~~
Coverage decreased (-76.7%) to 14.8% when pulling 6550282a3b28eb327fa502daa2b9682c71235f55 on bjansen:issue-57-junit5 into d43da049898e5619c9ad1ea24c98d0a00124ef7e on zapodot:master.
I realized it might be a better design to split the code into separate modules, like what was done in https://github.com/zapodot/embedded-jms-junit for example. Better separation of concerns, no dual dependency on JUnit 4 and JUnit 5 etc. But that will introduce quite a lot of changes in the project structure. WDYT @zapodot?
Thanks for your contribution! You are right: It would be better to split JUnit 4 and JUnit 5 support into two separate modules.
All right, I think I can get it to work without breaking compatibility with older versions (especially the Maven coordinates).
One remaining problem after modularization: most of the unit tests are in embedded-ldap-junit
, but most of the code is in embedded-ldap-core
, so cobertura reports very low coverage even when most of the code is well tested.
Good news! I moved (actually copied) most of the unit tests from embedded-ldap-junit
to embedded-ldap-core
, and the coverage is now on par with what's currently on master.
I suppose I could remove most of the tests in embedded-ldap-junit
which are now redundant, and only leave what's testing the actual JUnit rule stuff, and not the embedded LDAP server. WDYT @zapodot?
So, to summarize:
- The project is now split into 3 modules:
-
embedded-ldap-core
contains most of the code to setup an embedded LDAP server, and is not tied to any testing framework. It has good code coverage. -
embedded-ldap-junit
is a JUnit 4 rule that starts this embedded LDAP server -
embedded-ldap-junit5
is a JUnit 5 extension that starts this embedded LDAP server
-
- This new version should not break anything in existing projects, because Maven coordinates remain the same (the only difference is that
embedded-ldap-junit
now has an extra dependency onembedded-ldap-core
). Package names and class names remain the same. - Now that the project is modularized, it's possible in theory to add support for new testing frameworks that have an equivalent of JUnit's
@Rule
.
I think there's an extra change that I could do: embedded-ldap-core
is now mostly abstract classes, but I could add a Simple
/Default
implementation that would turn the thing into a standalone module.
People who want to embed a simple LDAP server in their application (outside of the context of unit tests) could simply pull embedded-ldap-core
and use its builder to set up their server!
Any updates on this PR? 🤔
@bjansen any chance that you can rebase from the master branch?
bump....
I rebased from master, I'll probably squash the commits before merging.
@bjansen @zapodot Any idea when this could be merged? It's kind of usefull :wink:
@zapodot do you think you could find some time to review this PR?