Products Downloads


French version


 

The machine used for the test run must be a Windows machine:

  • on which Adelia is installed,
  • which has access to the Adelia environment, which contains the test programs.


a) Setting up a test project


Create a directory in which you will place all the files and all the directories picked up in %ADELIWS%\Unit_Tests\Maven.


Changes to the build.gradle file:


import javax.xml.transform.stream.StreamSource

import javax.xml.transform.stream.StreamResult

import javax.xml.transform.Source

import javax.xml.transform.Transformer

import javax.xml.transform.TransformerFactory

apply plugin: 'java'

group = '[ORGANISATION ID]'

version = '[PROJECT VERSION]'

description = "Adelia unitary test"

tasks.withType(JavaCompile) {

    options.encoding = 'UTF-8'

}

repositories {

        mavenLocal()

        mavenCentral()

}

dependencies {

    testCompile fileTree(dir: "${System.env.ADELIWS}javarun" , include: '*.jar')

testCompile "junit:junit:4.9"  

}

task adelGen {

doLast{

if (System.getProperty("skip.gen.test.pgm") == null) {

exec{

environment  "javaSourceDirectory" , "${projectDir}\\src\\test\\java\\"

environment  "CLASSPATH" , "${System.env.ADELIWS}javarun;${System.env.ADELIWS}javarun\\*"

//*******************************************************************

environment  "adeliaEnvironment" ,"[ENVIRONMENT NAME]"

environment  "adeliaTask01" , "[ADELIA TASK NAME]"

//*****************************

environment  "winJavaSvrDir" , "[WINDOWS JAVA SERVER DIRECTORY]"

environment  "AS400SvrLib" , "[AS/400 SERVER LIBRARY]"

environment  "AS400SvrHost" , "[AS/400 SERVER HOST]"

environment  "AS400SvrPort" , "[AS/400 SERVER PORT]"

environment  "AS400SvrProfile" , "[AS/400 SERVER PROFILE]"

environment  "AS400SvrPwd" , "[AS/400 SERVER PASSWORD]"

environment  "AS400SvrEncryptPwd" , "[AS/400 SERVER ENCRYPTED PASSWORD]"

environment  "AS400SvrJobdLib" , "[AS/400 SERVER JOBD LIBRARY]"

environment  "AS400SvrJobdName" , "[AS/400 SERVER JOBD NAME]"

//*******************************************************************

executable "AGPTS.exe"

}

}

else {

copy{

from "${System.env.ADELIWS}CHKTSTREF.java"

into "${projectDir}\\src\\test\\java\\com\\hardis\\adelia\\test"

rename 'CHKTSTREF.java' , 'CHKTST.java'

}

}

}

}

compileTestJava.mustRunAfter(adelGen)

// **********************************************************************

task [GRADLE TASK NAME](type : Test , dependsOn: adelGen ) {

group 'adeliaUnitTest'

ignoreFailures true

systemProperty 'adeliaPhysicalServerHost', '[MIDDLEWARE SERVER]'

systemProperty 'adeliaPhysicalServerPort', '[PORT]'

systemProperty 'adeliaPhysicalServerProfile', '[MIDDLEWARE PROFILE]'

systemProperty 'adeliaPhysicalServerPassword', '[PASSWORD]'

systemProperty 'adeliaLogicalServer', '[LOGICAL SERVER NAME]'

systemProperty 'adeliaDatabase', '[DB TEST NAME]'

include '**/*.class'

exclude 'com/hardis/adelia/test/CHKTST.class'

}

// ***********************************************************************

test {

systemProperty 'adeliaTestType', 'gradle'

systemProperty 'reportDirectory' , "${projectDir}\\build\\test-results\\"

systemProperty 'noXslStyleSheet', 'true'

include 'com/hardis/adelia/test/CHKTST.class'

}

gradle.taskGraph.afterTask { task, state →

if ( task.name == "test") {

def xslt= new File("${System.env.ADELIWS}AdeliaTestsReport.xsl").getText()

def transformer = TransformerFactory.newInstance().newTransformer(new StreamSource(new StringReader(xslt)))

def xml= new File("${projectDir}/build/test-results/AdeliaTestsReport.xml").getText()

def html = new FileOutputStream("${projectDir}/build/test-results/AdeliaTestsReport.html")

transformer.transform(new StreamSource(new StringReader(xml)), new StreamResult(html))

logger.lifecycle("Global test Report: file:///${projectDir}/build/test-results/AdeliaTestsReport.html")

}

}

test.dependsOn {tasks.findAll { task ->  task.group == "adeliaUnitTest" }}



The parameters are as follows:

ORGANISATION ID

Identifier of the organization (e.g. com.mycompany.myappli)

PROJECT VERSION

Version of your project (e.g.1.0.0)

ENVIRONMENT NAME

Name of the Adelia environment containing your test programs

ADELIA TASK NAME

Name of the Adelia task containing your test programs

If your test programs are spread over several Adelia tasks, create additional elements: <adeliaTask02> , <adeliaTask03>…  (consecutively numbered and limited to 99 maximum).

WINDOWS JAVA SERVER DIRECTORY

Full name of the root directory in which the sources and objects of Windows or Java server parts for your test programs will be generated.
Caution: You should remember to double the \ symbol in the path (for example: C:\\myDir1\\myDirGen)
This parameter is optional.
It is not specified, the standard parameters of your environment will be used.
If is specified, then the C or Java compilation will use the C or JDK compiler which is installed on the machine used for carrying the test.
The sources of the Windows server parts will be placed in the WinServer\src sub-directory.
The objects of the Windows server parts will be placed in the WinServer\obj sub-directory.

The sources of the Java server parts will be placed in the JavaServer\src sub-directory.

The objects of the Java server parts will be placed in the JavaServer\src sub-directory.

AS/400 SERVER LIBRARY

Library in which the sources and objects of the AS/400 server parts of your test programs will be generated.
This parameter is optional.
It is not specified, the standard parameter of your environment will be used.

AS/400 SERVER HOST

Host name or IP address of the AS/400 on which the AS/400 server parts of your test programs will be compiled.
This parameter is optional.
It is not specified, the standard parameter of your environment will be used.

AS/400 SERVER PORT

Listening port used by the Adelia daemon for the AS/400 on which the AS/400 server parts of your test programs will be compiled.
This parameter is optional.
It is not specified, the standard parameter of your environment will be used.

AS/400 SERVER PROFILE

User profile to be used for connecting to the Adelia daemon of the AS/400 on which the AS/400 server parts of your test programs will be compiled.

This parameter is optional.

It is not specified, the standard parameter of your environment will be used.

AS/400 SERVER PASSWORD

Password in unencrypted format associated with the user profile and which is to be used for connecting to the Adelia daemon of the AS/400 on which the AS/400 server parts of your test programs will be compiled.
This parameter is optional.
If it is specified, then the SERVER ENCRYPTED PASSWORD value must not be specified.
It is not specified, the standard parameter of your environment will be used.

AS/400 SERVER ENCRYPTED PASSWORD

Password in encrypted format associated with the user profile and which is to be used for connecting to the Adelia daemon of the AS/400 on which the AS/400 server parts of your test programs will be compiled.
The encryption algorithm corresponds to the one used for the mwclient.ini file's password (or to the encryption algorithm provided by the VaToolBxEncryptAdeliaPassword function).
This parameter is optional.
If it is specified, then the SERVER PASSWORD value must not be specified.
It is not specified, the standard parameter of your environment will be used.

AS/400 SERVER JOBD LIBRARY

Job description library name to be used for the compilation context of the AS/400 server parts of your test programs.
This parameter is optional.
It is not specified, the standard parameter of your environment will be used.

AS/400 SERVER JOBD NAME

Job description name to be used for the compilation context of the AS/400 server parts of your test programs.
This parameter is optional.
It is not specified, the standard parameter of your environment will be used.

GRADLE TASK NAME

Name of the Gradle task performing the test (this name must be different from "test").

This name will be visible in the test report.

For example, if two Gradle tasks were defined to run the tests in the context of a Windows Middleware server and an AS/400 Middleware server, the first test could be named WINDOWS_SERVERtest and the second AS400_SERVERtest.


The following parameters are not strictly speaking Framework parameters but are an illustration of the method used to transmit contextual information from the build.gradle file to the test programs.

In this case, these parameters are used to manage the dynamic Middleware connection used by the TEST_CONFIG management rule.

MIDDLEWARE SERVER

Name or IP address of the Middleware server

PORT

Listening port of the Middleware demon

MIDDLEWARE PROFILE

Middleware connection profile.

PASSWORD

Password associated with the Middleware profile

LOGICAL SERVER NAME

Name of the logical server used by the test programs

DB TEST NAME

Name of the test database defined in the server configuration file.

*DFT corresponds to the default base and

* NONE is used when it is not required to connect to a database.



If you need more execution contexts for your tests, you can add a second execution block. To do this:

  • duplicate the block of the "[GRADLE TASK NAME]" task and
  • change its name and adjust its parameters.


If some test programs must run in a particular execution context (and then for a specific test task) and not in another, you can set this particular case using <include> and <exclude> tags, naming the java class path directly.

Be sure to use / instead of a dot in the package.

You can use generic names with regard to a package (e.g. com/mestests/AS400/*.java): if you put your test programs in different tasks, they can have a different package even if they are in the same application area.



b) Runnning the test


Caution: if your test programs have AS/400 server parts, you must be, on your AS/400, at least at the level of PTF F003 of the AS/400 part of Adelia Studio 13.


To run the test, open a Windows command window, navigate to the directory of your test project (the one that contains your build.gradle file) and run the following command:

gradlew clean test


Note: when you first run the command, your machine must have an Internet access so that Gradle can download some components cited in the build.gradle file.


If no error is detected during the preparatory phase of the tests (analysis of the build.gradle file and generation of test programs) you will find the unit test report files AdeliaTestsReport.xml and AdeliaTestsReport.html in your test project directory in the "build/test-results" directory.

The AdeliaTestsReport.html presents the results as shown below:




Notes: 

If the "noXslStyleSheet"; property of the ";test"; task is set to 'false', then the AdeliaTestsReport.xml file will be associated with a style sheet (AdeliaTestsReport.xsl) which allows the results to be presented in the Microsoft Edge or FireFox browser, in the same way as in the AdeliaTestsReport.html document (caution: local style sheets are not accepted by the Chrome browser).


If you want to rerun the same tests as those carried out during the previous run, but skipping the step of generating test programs, you can do this by running the following command:

gradlew -Dskip.gen.test.pgm=true clean test


List of error codes:

Errors related to executing the plug-in: org.codehaus.mojo: exec-maven-plugin

-1 to -4: Errors related to the ADELJOB command

-5: Generating or compiling a test program has failed (open the job manager for more information about the error)

-10: A task specified in an adeliaTaskxx tag does not exist in the environment

-11: A task specified in an adeliaTaskxx tag does is not a test type task

-50: Could not load an Adelia product dll

-51: The name of the Adelia environment is not specified in the build.gradle file

-52: Error connecting to the environment

-53: Error retrieving information about the environment.

-55: Error copying the file com/hardis/adelia/test/CHKTST.java under the test project directory


↑ Top of page

  • Aucune étiquette