Category: Junit
Junit Test
Junit’s annotation based expected exception testing
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. A Java unit test should…
Using Jetty Server with Junit test
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 a maven project in Eclipse.
JUnit Mockito doNothing Example
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.
JUnit Mockito doReturn 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.
Convert List, Map to JSON in REST Response using Jersey
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 URI of the REST resources….
Cucumber Test Framework – Cucumber-JVM with Cucumber-Java + Cucumber-Junit
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 the Gherkin parser but implement…