Skip to main content

Blog Post #1 JUnit 5 Testing

In class, we have been learning about testing with Junit 5 and doing assignments related to it. After watching the video for the advanced part of the assignment,  I decided that I wanted to research further into the topic for my first blog post. So, what is Junit? In a short answer, JUnit is a Java open sources unit testing framework that is used to write and run repeatable automated tests. JUnit 5 Is the updated version of the highly popular testing library that is Junit 4 which I’m sure you all have heard of it. Junit 5 was released in 2017 that adds good use for Java 8 features. In fact, JUnit 5 requires Java 8 JDK or higher to work.

While researching a few of the key differences between the two versions are Junit 5 is composed of 3 sub-projects JUnit Platform, JUnit Jupiter, and JUnit Vintage. The Assertions and Annotations have been changed, and most importantly Junit 5 adds the support of the lambda expression in which we went over in class. One of the blogs I read recommends doing this example,  which I found quite helpful and easy to understand. The code below is just a conversion between Fahrenheit to Celsius and Junit to test it. The author breaks each part down into subsections which made It easier to follow along. I was also, curious about how Junit 5 worked in the Gradle so I followed tutorials to see how the build systems provide supports to the new feature. I highly recommend watching the video that I have provided; it explains everything you need to know about Junit 5 and the architecture behind It.

 

Resources: 

https://www.youtube.com/watch?v=flpmSXVTqBI  

https://www.parasoft.com/junit-tutorial-setting-up-writing-and-running-java-unit-tests/

Comments

Popular posts from this blog

Sprint 3 Retrospective

https://gitlab.com/LibreFoodPantry/client-solutions/theas-pantry/reportingsystem Here is the Link to the repositories that contains everything we worked on Sprint-3. Backend, Frontend, Event system, and Keycloak. Connect RabbitMQ receive file to DB : Connected the MongoDB database on the received file. Implement Event System components: Implemented RabbitMq components for Event System. Meet with other Event System Teams. : Met with other teams to finalize everything about messages. New TheasPantryReport: The new Theas Pantry Report Create two channels for both teams: Created two channels for both teams on the send and receive files.   For this Sprint, I worked mainly with Austin on the backend components such as implanting the rabbbitMQ, making API, and trying to get out system working. What worked well / did not work well For this sprint, what worked best was that we got our reporting system functioning. We have a system where the Rabbitmq receives the messa...

Testing with Mockito

During class, we have been doing many testing methods including Junit 5 and for the past two weeks we have been using Mockito, so for today’s blog, I want to focus more on the framework and testing with Mockito. Before we get started let us talk about what is mocking. Mocking is a process of developing the objects that act as the mock or clone of the real objects. In another word, mocking is a technique where mock objects are used instead of real objects. The purpose is to isolate and focus on the code being tested. Mock uses objects such as Fakes, Stubs, and mocks. A fake object has working implementation but takes shortcuts which makes them not suitable for production. Stub object usually does not respond to anything outside that is programmed in for the test. Mocks are objects that are preprogrammed with expectations which form a specification of the call that is called to receive. Now let us move on to what Mockito is, Mockito is a java based mocking framework ...