spectrum
spectrum copied to clipboard
JUnit 5
We don't have an immediate need for JUnit 5, but as Spring moves forward we might want to start using it. Are there any plans to make Spectrum work with JUnit 5?
Certainly, I'd say JUnit5 is in the longer-term roadmap for Spectrum. I'd like to generalize Spectrum a bit so that it can run on multiple backend running/reporting frameworks like JUnit4, JUnit5, Cucumber or possibly others. We would have a set of adapters for running Spectrum tests on top of those various tools.
+1
I was also looking at putting this onto a project, and although (as @rkawala mentioned) it's not an urgent necessity, I think having JUnit 5 support would be great.
If you can elaborate on your plans for supporting JUnit 5, maybe someone (potentially me, if I get some time) can help by submitting a Pull Request.
Thanks!
@gajwani Thanks for reaching out (and sorry for not responding sooner!).
I touched on this a little bit Design Philosophy wiki page.
Overall, it might look like:
- Start the process of decoupling the existing codebase from JUnit 4 (with adapters/interfaces as necessary). A
spectrum-corewould probably emerge that is agnostic of which framework gets used (the outermost layer). This is probably a multi-PR process over time (and we've already been moving in this direction). - Split out the distribution so that
spectrum-junit4(which would depend onspectrum-core) can be used as a drop-in for the original (as-is today) Spectrum package. - Implement a
spectrum-junit5package (again, depending onspectrum-core) that runs on top of the latest JUnit5 framework.
Full disclosure, I haven't learned much about the JUnit5 migration path. I do know that they intend for the versions to not conflict with each other, so perhaps there is a better way. I'm very much interested in ideas and feedback.
From what I have read, it does seem like integrating Spectrum on top of the JUnit5 Platform API (TestEngine) will be much simpler, since there is a direct abstraction available for non-traditional test runners like ours.
From what I have read, it does seem like integrating Spectrum on top of the JUnit5 Platform API (
TestEngine) will be much simpler, since there is a direct abstraction available for non-traditional test runners like ours.
Yes! That is indeed the idea behind the TestEngine abstraction. 😉
JUnit 5 support would actually be great. I was just about writing a Jasmine-style extension myself when I though I should google it first. So is there any plan to support it since JUnit 5 is getting a lot of traction right now?
From what I have read, it does seem like integrating Spectrum on top of the JUnit5 Platform API (TestEngine) will be much simpler, since there is a direct abstraction available for non-traditional test runners like ours.
I've actually forked the repo to play with it. I've removed the junit-4 deps to see what breaks. So I see a couple of issues that needs to be addressed.
- The current implementation is coupled to Junit 4.
Spectrumprovides both an API and is a testRunnerimplementation at the same time. I'm a bit uncertain about how we would expose the API to the test class. Extending the test class withSpectrum? - The
Suiteclass is a mix of describing the tests (JUnit 4Description) as well as holding the actual tests and executing them. This needs to be decoupled as already mentioned. - The concept of a JUnit 4
Runnerimplies that it will be called for each test class annotated withSpectrum. ATestEngineis instantiated only once per test run and needs to know all tests and is able to filter for specific tests. So we need to have one abstraction that supports both.
Full disclosure: This is the first time I was looking into the Spectrum code base, so I might get stuff wrong.
For reference, I looked into jqwik which already implements TestEngine.