Introduction In this tutorial we will see how to write Junit test cases on Spring REST services. Before continue to reading this tutorial please read first Spring RESTful Webservice CRUD Example We have total four operations on this REST example. If you want you may add more operation such as find all products and apply…

Posted in Junit Spring REST

Junit Testing Spring REST Services

For your Java application you need to check the code coverage of your Junit test classes. Code coverage ensures your code quality for the Junit test cases you have written for your functionalities of the application. Here I am going to show you how you can use Jacoco plugin to test the coverage. Currently it…

Posted in Gradle Junit

Junit Code Coverage using Gradle, Jacoco

In this example I am going to explain how to use a test suite in Junit testing framework in Java programming language. A test suite bundles a few unit test cases and runs them together. In Junit, both @RunWith and @Suite annotations are used to run the suite test. Junit Classes : Junit classes are…

Posted in Java Junit

Junit 4 Test Suite Example in Java

Introduction In this post I will show you how to work with Junit code coverage with JaCoCo code coverage library, which is quite a new maven plug-in that provides the JaCoCo runtime agent to your tests and allows basic report creation. Currently it supports instruction, branch, line, method and class coverage which is pretty enough…

Posted in Junit

Junit Code Coverage with Jacoco

Junit provides an option of tracing exception thrown by a Java method. There are different ways of handling exceptions in JUnit tests. Standard Junit’s org.junit.Test annotation offers expected attribute that allows you specifying the a Throwable to cause a test method to succeed if an exception of the specified class is thrown by the method….

Posted in Java Junit

Junit’s annotation based expected exception testing

In this post I will show you how to use Jetty server with Junit test case and how to deploy web application using Java program in Junit test. If you already have an idea on how to create a maven project in Eclipse will be great otherwise I will tell you here how to create…

Posted in Junit Server

Using Jetty Server with Junit test

Introduction In this post, I will be showing Junit mockito doNothing example in one of the most widely used and popular JUnit Testing Mocking framework – Mockito. I am going to use PowerMock API to test Java classes. I am going to show you when to use doNothing() method.

Posted in Junit

JUnit Mockito doNothing Example

In this post, I will be showing one of the most widely used and popular JUnit Testing Mocking framework – Mockito. Mockito is one of the widely used testing API for Java. I am going to show you how to work with doReturn() and when to use it for testing your Java class using Junit.

Posted in Junit

JUnit Mockito doReturn Example

Introduction In this post we will see how to convert List, Map to JSON in REST Response using Jersey API. We will create three separate REST methods to convert List to JSOn, Map to JSON and List of Map to JSON string. We will annotate the REST resource class with @Path for having the base…

Posted in Junit REST

Convert List, Map to JSON in REST Response using Jersey

Introduction Cucumber test framework is a tool for running automated acceptance tests written in a behavior-driven development (BDD) style. Cucumber test framework is written in the Ruby programming language. Cucumber projects are available for other platforms beyond Ruby. Some use Ruby Cucumber with a bridge into the target language (e.g. cuke4php and cuke4lua). Others use…

Posted in Cucumber Junit

Cucumber Test Framework – Cucumber-JVM with Cucumber-Java + Cucumber-Junit