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.

 

Ensure that your test programs generate their Java client source in the directory <project directory>\src\test\java by putting this path:

  • either in the "Java client " page of the environment attributes (public programs) or of the logic level of the application area (private programs).
  • or at the level of the test tasks to which they are assigned.

 

Changes to the build.gradle file:

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  "adeliaEnvironment" ,"[ENVIRONMENT NAME]"

environment  "adeliaTask01" , "[ADELIA TASK 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', 'false'

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

}

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).

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 file AdeliaTestsReport.xml in your test project directory in the "build/test-results" directory.

A style sheet is associated with this file (AdeliaTestsReport.xsl). It is used to present the results in an Internet Explorer, Microsoft Edge or FireFox browser as an HTML page like the one shown below:

 

 

 

Caution: local style sheets are not accepted by the Chrome browser. You can disable taking the style sheet into account by replacing "false" by "true" in your build.gradle file for the "noXslStyleSheet" tag of the "test" task.

 

Note: 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