Software Development is a science as well as an art, it involves so many processes and refinements to produce creative solutions, as with all other things in life, it is prone to errors due to human involvement. These errors occur as a result of so many things, sometimes because of a requirement or condition that never occurred to the mind of the developer who was developing the solution or because of a glitch in the components on the production environment. Whatever the reason might be, one thing is certain it’s very obvious that software solutions need to be well tested(automated tests not manual tests) in order to ensure high standard quality, this is where Test Driven Development comes in.
TEST DRIVEN DEVELOPMENT
Test driven development is a software development process which embraces tests as an integral part of software development not as an after-thought. In this form of software development, test cases are gotten from the project requirements in small increments and are written even before writing the business logic code to accomplish the project requirements, the test cases are written to cover all scenarios possible to ensure that the code that it will be tested against is of high quality and free from errors. The flow is basically like this:
- You have a feature you want to implement that’s part of the main project.
- You write tests for that feature in a testing framework for the platform you choose to use(in our case that would be JUnit) before writing the code to implement the feature.
- You write the code to implement the feature.
- You run the tests against the code to ensure that the code passes all the test.
- You repeat the same process for the next feature.
This very much ensures that all features get tested very well and unnecessary code isn’t written. By following this process of development you can even go as deep as dividing each feature into units and testing for those units to have even more quality code.
JUnit5 is the next version of Junit which is one of the major testing frameworks in the Java ecosystem that enables you to write quality tests, it actively supports the Test Driven Development practice which highly enhances productivity
Features Of JUnit5
- It has a great community. This very much means that there are practically a lot of resources in terms of tutorials, forums e.t.c so if you get stuck anywhere you can easily find a way through the community and you can also be rest assured that support for it is not going to disappear.
- It is open source. Junit is fully opensource, you can take a look at the core code on github and use it for your projects for free.
- It is simple, elegant, easy to learn and saves you a lot of time that would have been spent on debugging errors.
- It fully takes advantage of Java 8 features such as lambdas.
- It’s further optimized for more speed and more testing capabilities.
JUnit 5 is composed of different components gotten from three sub projects which are:
- JUnit Platform: This is the core platform itself.
- JUnit Jupiter: This contains all the new features.
- JUnit Vintage: This primarily exist to backwards compatibility.
In the next few posts, we are going to be walking through JUnit5 from beginners level to a working level.
Next setting up your testing environment