Quantcast
Channel: Unit Testing - HowToDoInJava
Browsing all 21 articles
Browse latest View live

Unit testing best practices : Junit Reference guide

Before writing this post, I am assuming that you know the basics of junit. If you do not have the basic knowledge, first read this link. Further, in this post,... The post Unit testing best practices :...

View Article



How to write parameterized testcases with junit 4

As a developer, we all have written Junit testcases at some stage of our career. They are like one strong pillar of your product development life cycle. We have also... The post How to write...

View Article

Ordered testcases execution in junit 4

If you have ready my previous post about best practices for JUnit testcases, you will find out that writing ordered testcases is considered bad practice. But, still if you caught... The post Ordered...

View Article

Junit testcases which expects exception on runtime

Junit is a unit testing framework for the Java programming language. If you want to read about best practices followed for junit testing then here is an excellent guide for... The post Junit testcases...

View Article

Assumption based testcases in junit 4

Junit is a unit testing framework for the Java programming language. If you want to read about best practices followed for junit testing then here is an excellent guide for... The post Assumption based...

View Article


How to unit test spring security authentication with junit

In last few tutorials, we learned about different ways to secure your web application using spring security 3. We learned about xml user details, JDBC based user details service and... The post How to...

View Article

8 signs of bad unit test cases

If you have been in software development for a long time, then you can easily relate with the importance of unit testing. Experts say that most of bugs can be... The post 8 signs of bad unit test cases...

View Article

TestNG Tutorial (With Eclipse)

Testing as you may know is the process of validating and verifying that a piece of software or hardware is working according to the way it’s expected to work. Testing is a very important part of the...

View Article


TestNG Annotations Tutorial

TestNG uses annotations to help developers to write the tests. The following is a table containing information about all the annotations provided by TestNG and a brief description of them. I will cover...

View Article


TestNG Before and After Annotations

Before and After annotations are mainly used to execute a certain set of code before and after the execution of test methods. These are used to basically set up some variables or configuration before...

View Article

TestNG – Timeout Test Tutorial

While running tests there can be cases where certain tests get stuck or may take much more time than expected. In such a case you may need to mark the said test case as fail and then continue. In this...

View Article

How you should unit test DAO layer

If you are working in a project built on Spring, hibernate or JPA, and you want to unit test it’s data access layer (DAO) then information given in this tutorial may help you. As we are going to test...

View Article

FIRST Principles for Writing Good Unit Tests

In any application, which solves real world problems, having problems in it’s unit tests – is least desirable thing. Good written tests are assets while badly written tests are burden to your...

View Article


JUnit Best Practices Guide

I am assuming that you know the basics of JUnit. If you do not have the basic knowledge, first read JUnit tutorial (Updated for JUnit 5). Now we will go through the junit best practices you must...

View Article

Mockito annotations – @Mock, @Spy, @Captor, @InjectMocks

Learn about mockito annotations such as @Mock, @Spy, @Captor, @InjectMocks. Learn to write unit tests for behavior testing using mockito annotations. The post Mockito annotations – @Mock, @Spy,...

View Article


Mockito – Verify multiple method calls with different arguments

Learn to write unit test which invokes a method multiple times with different arguments – and then verifies the method invocations and method arguments separately. 1. Verify multiple method calls with...

View Article

TestNG – Expected Exception

With TestNG, while writing unit tests, there can be certain scenarios where we need to verify that an exception is being thrown by the program during execution. TestNG provides functionality to test...

View Article


Testing with Spring Boot 2.4 and JUnit 5

Learn to test a Spring boot 2.4 application which has JUnit 5 dependencies. We will see some very quick and simple examples of : Unit testing the application initializes successfully Unit testing REST...

View Article

Spring Boot @TestConfiguration Example

Learn to create and import test configurations in spring boot applications with the help of @TestConfiguration annotation. The post Spring Boot @TestConfiguration Example appeared first on HowToDoInJava.

View Article

Guide to JSONassert (with Examples)

Learn to write test result assertions using the JSONassert with easy-to-understand examples. We can use this tutorial as JSONassert cookbook for quick reference. The post Guide to JSONassert (with...

View Article
Browsing all 21 articles
Browse latest View live


Latest Images