Junit Testing for Multiple Files Upload Spring REST Controller

Introduction Here I am going to write Junit test case for testing multiple files upload in Spring REST Controller. I have already created how to upload multiple files using Spring REST API and I also had shown how to test it through REST client tool – Postman. In this tutorial I am going to use Junit 5, @WebMvcTest annotation to…

Java Junit 5 Mockito doNothing() Example

In this tutorial I am going to show you how to work with Mockito‘s doNothing() in Java Junit 5 API. Mockito‘s doNothing() or Mockito itself is widely used testing framework. If you are working with Junit 4 then you can read the similar example Mockito’s doNothing() using Junit 4. Mockito‘s doNothing() is used when you want to test void methods…

File Upload and File Download REST APIs Testing using Rest Assured in Java

Introduction In this tutorial I will show you how to test REST APIs used for file upload and file download. The file upload or download application might have been created using any server side technology. I am going to use here Rest Assured library with Junit 5 framework in Java programming language. I will use multipart for file upload test….

Cucumber Tags Example

Introduction In this tutorial you will see how to work on Cucumber Tags. Tags in Cucumber are great ways to organize your features and scenarios. It is pretty much simple when you have one, two, or maybe five scenarios in a feature file. However, in real life project, for each feature, you may have 20, 30, or may be more…

@WebMvcTest Annotation Example in Spring MVC Applications

Introduction We will see the use of @WebMvcTest annotation in Spring MVC applications. The Spring MVC application may be Spring Boot application as well. The @WebMvcTest annotation can be used not only to test Spring Controllers but also Spring REST Controllers. We will build the applications using both maven and gradle tools. @WebMvcTest annotation is used for unit testing of…

Junit 5 Parameterized Tests Examples

Introduction In this example we will create Junit 5 parameterized tests. In our previous example we have seen how to configure Junit 5 for Java projects. In parameterized tests it is possible to run a test multiple times with different arguments. The @ParameterizedTest annotation is used in the regular @Test methods to indicate parameterized tests. In addition, at least one…

How To Exclude Junit Tests Using Gradle Or Maven In Java Applications

Introduction Here in this tutorial I will tell you how to exclude Junit test cases from build automation in Java applications. It’s not about skipping test cases but it’s about excluding test cases for a particular package. Situations may arise when you want to exclude some Junit test cases from running in some environments (for example, uat, prod, etc.) while…

How to configure Junit 5 using Maven and Gradle in Eclipse

Introduction Here I will show you how to configure Junit 5 using maven and Gradle in Eclipse. To get started with Junit 5, you need at least a single TestEngine implementation, for example, junit-jupiter-engine. We will show here both maven and gradle version dependencies for Junit 5. This TestEngine will pull in all the required dependencies. Among those dependencies is…

Mock Activiti TaskService, TaskQuery, NativeTaskQuery in Junit

Introduction In this tutorial we will see how to mock Activiti TaskService, TaskQuery, NativeTaskQuery in Junit class. Suppose you have Spring service class where you are doing some business flow for your application. So you are using Activiti‘s TaskService to create a list of activiti Tasks using the method createNativeTaskQuery(). You may need to create also TaskQuery from TaskService using…

Mock Drools ObjectFactory, KieSession and StatelessKieSession using Junit

This tutorial example will show you how to mock ObjectFactory<KieSession>, KieSession and KieStatelessSession using Junit. KieSession is the most common way to interact with the engine in Drools. A KieSession allows the application to establish an iterative conversation with the engine, where the state of the session is kept across invocations. The reasoning process may be triggered multiple times for…