I'm a TestNG lover.
I think Junit is too limited for a complete customization of the test running
phase. I read many articles on the Junit
5 and its new features.
JUnit 5 = JUnit Platform + JUnit Jupiter + JUnit Vintage
- The JUnit Platform serves as a foundation for launching testing frameworks on the JVM. It also defines the TestEngine API for developing a testing framework that runs on the platform. Furthermore, the platform provides a Console Launcher to launch the platform from the command line and build plugins for Gradle and Maven as well as a JUnit 4 based Runner for running any TestEngine on the platform.
- JUnit Jupiter is the combination of the new programming model and extension model for writing tests and extensions in JUnit 5. The Jupiter sub-project provides a TestEngine for running Jupiter based tests on the platform.
- JUnit Vintage provides a TestEngine for running JUnit 3 and JUnit 4 based tests on the platform.
I appreciated the
the attempt to improve the Junit framework significally, reducing the impact on
AS-IS test suites based on Junit 3 or 4.
Some materils to
approach new paradigm:
Clearilly:
I found interesting
this github prject to start with a valid
configuration for MAVEN (gradle version is available):
The
junit5-maven-consumer project demonstrates how to execute tests based on JUnit
5 milestones using Maven. In addition, it showcases that existing JUnit 4 based
tests can be executed in the same test suite as JUnit 5 based tests or any
other tests supported on the JUnit Platform.
This sample project
does not aim to demonstrate how to use the JUnit Jupiter APIs. For detailed
information on the JUnit Jupiter programming and extension models.
Please note that
this project uses the Maven Wrapper. Thus, to ensure that the correct version
of Maven is used, invoke mvnw instead of mvn.
I think can be very
helpful a simple JUnit Jupiter extension to integrate Mockito into JUnit
Jupiter tests somewhat simpler.
The MockitoExtension
showcases the TestInstancePostProcessor and ParameterResolver extension APIs of
JUnit Jupiter by providing dependency injection support at the field level and
at the method parameter level via Mockito 2.x's @Mock annotation. See here:
Mockito is a mocking
framework that tastes really good. It lets you write beautiful tests with a
clean & simple API. Mockito doesn’t give you hangover because the tests are
very readable and they produce clean verification errors.
If you have read the
second link I reported (testing with spring) probably you can understand that
mockito and some feature of spring ofr test are the same.
For y first test i
used 'junit5 maven consumer', it implies the usage of surefire maven plugin.
I add two deails of
my environment:
- Junit 5 needs JDK8
- Apache maven 3.3.9
This is the base of
the my environment for unit tests.