JUnit Testing in XPages

This project is one part of the BuildAndTestPattern4XPages. It contains a plugin that gives you the capabilty to use JUnit Version 4.11 in your XPage application development.

Install instructions

Extract the update site and install the feature like you are doing it with the ExtLib -> http://www-10.lotus.com/ldd/ddwiki.nsf/xpAPIViewer.xsp?lookupName=XPages+Extensibility+API#action=openDocument&res_title=XPages_Extension_Library_Deployment&content=apicontent

Put the example database on your server and open the database via the browser. You will see the following screen:

Using the plugin

  1. First write a test. If you have no idea about JUnit testing. There is a good booke, which I can recommend: Test Driven Developement by Example (Kent Beck). But a test maybe looks like this:
    package org.openntf.junit.example;
    import static org.junit.Assert.*;
    import org.junit.Test;
    public class TestMock2 {
    
    @Test
    public void checkTrue() {
        assertTrue(true);
    }
    
    @Test
    public void checkFalse() {
        System.err.println("MOCK2SYSERR");
        System.out.println("MOCK2SYSOUT");
        assertFalse(true);
    }
    
    @Test
    public void checkEquals() throws InterruptedException {
        Thread.sleep(201);
        assertEquals(10, 10);
    }
    }
    
  2. Create a new XPages and include the TestSuite Control on this page. Reference to your new written class.
    Check the result on the browser.