unit-test namespace¶
unit-test generate¶
Generates a DataStage test case for one or more specified DataStage flows.
The optional -check-row-count-only
flag will cause the generation of a test case which checks row counts, rather than the default option which is to compare data row-by-row.
Example¶
$> mcix unittest generate \
-assets /opt/dm/mci/jobs \
-joblist ./joblist.txt \
-specs /opt/dm/mci/testspecs
unit-test execute¶
Run one or more MettleCI Unit Tests against one or more DataStage jobs.
The -reports
option is used to specify the directory into which the JUnit XML files produced by this command will be placed. Each job tested will produce a separate XML file named after the Job (e.g. Job MY_JOB_ABC will produce a JUnit file named MY_JOB_ABC.xml)
The -ignore-test-failures
option will prevent a failing Unit Test from being interpreted as a command failure by your build system, and consequently halting your CI/CD pipeline.
See Repeatable DataStage Project Deployments for more details on how the -project-cache parameter is used to implement incremental tests. For more information on using the -project-cache
parameter see our detailed explanation.
The 'ignore-test-failures' option¶
MettleCI unit tests can be executed in two ways:
- Manually, using the Cloud Pak interface, or
- From the command line using the
mcix unit-test execute
command.
When using the MettleCI command line to execute unit tests from within a build orchestration system (Jenkins, GitHub actions, Bamboo, etc.) it’s important to understand how the mcix unit-test execute
command and your build system interact.
Calling the mcix unit-test execute
command has three potential outcomes:
- The command executes successfully and runs a unit test which passes,
- The command executes successfully and runs a unit test which fails, or
- The command fails to execute for any reason, and the unit test is never invoked (e.g. due to a misconfigured parameter such as referencing a non-existent unit test)
Like all shell commands, the mcix unit-test execute
command returns an exit code informing the host system of the success, or otherwise, of the invoked process - in this case a DataStage test case. By default, the mcix unit-test execute
command returns a non-zero (failure) result when either the command cannot complete or when a unit test fails. For many build orchestration systems this will cause the build to fail instantly and, most importantly, prevent the publication of the failed test’s associated JUnit XML file, making the process of diagnosing the test failure difficult.
The mcix unit-test execute -ignore-test-failures
option will prevent a failing unit test from being interpreted as a command failure by your build system, and consequently halting your CI/CD pipeline.
Example¶
C:\> mcix unit-test execute ^
-domain test1-svcs.datamigrators.io:59445 ^
-server test1-engn.datamigrators.io ^
-username isadmin ^
-password my_password ^
-project my_project ^
-specs unittest ^
-reports unittest_reports ^
-project-cache "/mettleci/cache/test1-engn.datamigrators.io/my_project"
MettleCI Command Line (build 128)
(C) 2018-2025 Data Migrators Pty Ltd
unit-test execute (1.0-SNAPSHOT)
Reading test cases...
Executing 4 test cases with 2 concurrent jobs...
* Test TxFactFinanceDs - PASSED (28s)
* Test TxFactFinanceDs-test - PASSED (29s)
* Test ForJustin - PASSED (27s)
* Test TxTransformedSales - PASSED (35s)
SUCCESS: Executed 4 tests
C:\>