ILEUnit - Unit Test Framework for ILE enabled languages

Getting Started

The source package can be downloaded from the project page. Upload the package to the IBM i server. If you are using FTP don't forget to transfer the file in binary mode (bin). The sources are stored and packaged as stream files. So they need to be stored in the IFS. It is best to create a folder to store all stream source files.

	mkdir /usr/local/src
        mv ileunit-1.0.0-b1.tar /usr/local/src
        cd /usr/local/src
	tar -xf ileunit-1.0.0-b1.tar 
	

It is best to have a separate folder for the copybooks/include files.

	mkdir /usr/local/include
	

The file Makefile has to be in a normal stream file CCSID. You can check the CCSID with f. e. ls -alS. The other source files can have any valid CCSID, like 37 for US or 273 for DE. There is a convenient script at rpgnextgen.com which converts files into another CCSID (via iconv). Just download the script and execute it.

	./convert.sh /usr/local/src/ileunit 37
	

This will convert all files to a CCSID with 37 expect some special files like Makefile which will get a CCSID of 819.

Prerequisites

The unit testing framework relies on the following packages:

 

You can get these packages from the download section at rpgnextgen.com.

Compilation

To compile the source it is best to enter the QShell (enter QSH). The script to be used for building the framework is a Makefile. To check if the tool make is installed just enter which make. The Makefile is a simple text file with build instructions for the make tool. It can be edited like any other stream file.

The Makefile has some variables like the destination library for the compiled binaries, the binding parameters for the service program and the destination folder for the include files.

The variable can be simply overridden.

	make BIN_LIB=PRODLIB INCLUDE=/usr/other/local/include all
	

Note: Make sure to have LLIST and REFLECTION accessable from your library list.
 

Include Files

The unit tests need some files to be included (copy books) from the ILEUnit framework. To install them in your include folder use the make tool.

	make BIN_LIB=PRODLIB INCLUDE=/usr/local/include install
	

Test

The ILEUnit package comes with a very simple unit test, see unittest folder. Unit tests can be directly created from stream files.

	IUCRTTST TSTPGM(YOUR_LIB/ILEUNIT_01) SRCSTMF('/usr/local/src/ileunit/unittest/ileunit_01.rpgle') 
		INCDIR('/usr/local/include')
	

To run the simple unit test use the IURUNTST command.

	IURUNTST TSTPGM(YOUR_LIB/ILEUNIT_01)
	

The output should be: Success. 1 test case, 3 assertions, 0 failure, 0 error.

Congratulations! You installed and tested the unit testing framework ILEUnit. Happy testing =)