Skip to main content
Version: v10.15

Integrating JUnit Tests for WaveMaker Application


JUnit is a unit testing framework for the Java programming language. JUnit has been important in the development of test-driven development. These tests are required whether imported services are working as expected or not, before proceeding to run/deployment of the application. This document demonstrates how to integrate JUnit tests in an application developed by WaveMaker RAD.


  1. Integrate JUnit tests in the WaveMaker application
  2. Writing sample test cases for services.


  1. IDE (IntelliJ IDEA, Eclipse)
  2. WaveMaker Application
  3. Git
  4. Maven

Integrating JUnit Tests into App


  1. Export the WaveMaker application as a zip file.
  2. Import this zip file into IDE (Use WaveMaker workspace sync plugin).
  3. Add the following dependencies in pom.xml file under the dependencies tag.

  1. Create a file with name project-springapp-test.xml in src/test/resources folder
  2. Add below snippet to the file

<?xml version="1.0" encoding="UTF-8" standalone="no"?>
<beans xmlns=""
<import resource="file:src/main/webapp/WEB-INF/project-springapp.xml"/>
  1. Go to folder src/test/java and create a package namely com/{appName}/test/core
  2. Add a file with name
  3. Add code snippet to the file

package com.<appName>.test.core;

import org.junit.runner.RunWith;
import org.springframework.test.context.ContextConfiguration;
import org.springframework.test.context.junit4.SpringJUnit4ClassRunner;
import org.springframework.test.context.web.GenericXmlWebContextLoader;
import org.springframework.test.context.web.WebAppConfiguration;

@ContextConfiguration(loader = GenericXmlWebContextLoader.class,
locations = "classpath:project-springapp-test.xml", initializers =
public abstract class BaseTest {


Writing Test Cases

  1. Now start writing test classes under src/test/java package with a class extending BaseTest and with annotation @Test
  2. Code snippet for a sample test
import com.<appName>.test.core.BaseTest;
import com.<appName>.myjavaservice.MyJavaService;
import org.junit.Assert;
import org.junit.Test;
import org.springframework.beans.factory.annotation.Autowired;

public class MyJavaServiceTest extends BaseTest {

private MyJavaService myJavaService; // MyJavaService is the Java Service added in app

public void getJsonData() {
Object jsonData = myJavaService.returnJSONData();

See Also

How to send emails using Java Service
How to implement forgot password feature using Java Service
How to schedule a Java Service
How to accomplish Pre-Post Processing for a DB Service APIs