Hello guys, If you done some professional Java development then you know that Unit testing is a very, very important thing to learn to adapt. I would say this is the single most important practice in my opinion, which differentiates an excellent programmer with a professional programmer. It's one way you can see how disciplined a programmer is? It's also the best way to write clean code; a code that can stand the test of time, a code that is flexible enough to accommodate future changes and a code that you don't afraid of while changing. Despite several efforts of promoting unit testing by programming community and emphasizing unit testing by many notable programmers, it's still one of the lacking practice.
Friday, October 10, 2025
Saturday, July 12, 2025
JUnit4 Annotations : Test Examples and Tutorial
JUnit4 Annotations are a single big change from JUnit 3 to JUnit 4 which is introduced in Java 5. With annotations creating and running a JUnit test becomes easier and more readable, but you can only take full advantage of JUnit4 if you know the correct meaning of annotations used on this version and how to use them while writing tests. In this
Junit tutorial we will not only understand the meaning of those annotations but also we will see examples of JUnit4 annotations. By the way, this is my first post in unit testing but if you are new here than you may like post 10 tips to write better code comments and 10 Object-oriented design principles for Programmer as well.
JUnit Testing Tips - Constructor is Called Before Executing Test Methods? Example
Even though almost all Java programmers either use JUnit or TestNG for their unit testing need along with some mock object generation libraries e.g. Mockito, but not everyone spends time and effort to learn subtle details of these testing libraries, at least not in proportion to any popular framework like Spring or Hibernate. In this blog post, I am sharing one of such detail, which has puzzled me a couple of years ago. At that time, though I had been using JUnit for a significant time, I wasn't aware that code written inside the constructor of the Test class is executed before each test method.
Subscribe to:
Comments
(
Atom
)