UnitTest Test Command
Purpose
Run one or more MettleCI Unit Tests against one or more DataStage jobs.
Pay close attention to the pre-requisites and parameter descriptions for this command to optimise your efforts to get it running. This command is usually run as part of an automated continuous integration process in order to provide fast feedback to DataStage teams on whether a new DataStage solution build (triggered by one or more commits to a version control repository) has progressed or regressed the state of the solution.
A mandatory pre-requisite for executing this command is that any Unit Test cases to be executed have been copied to the /<METTLECI_HOME>/specs/<PROJECT_NAME>
directory of the target DataStage Engine host beforehand.
The path provided to the -specs
parameter must be for a folder containing test cases that is present on the same host as where the command is being executed. This can be either a full path (e.g. C:\path\to\the\latest\test\cases
) or a path that is relative to the location where the command is being executed (e.g. working\directory\test\cases
). The command uses the test cases found in this location purely to determine the names of Jobs it will attempt to run in test mode.
The path provided to the -reports
parameter must be for a folder that is present on the same host as where the command is being executed. This can be either a full path (e.g. C:\path\to\reports
) or a path that is relative to the location where the command is being executed (e.g. working\directory\reports
). The command uses the specified directory solely to write JUnit XML files for any Unit Test that is
skipped during execution; or
simply fails to execute (which is not the same as the test executing but producing a test result of “failed”).
The -reports
path isn’t used to write JUnit files for tests that have actually executed (i.e. produced a result of “passed” or “failed”), because those are written to the /<METTLECI_HOME>/reports/<PROJECT_NAME>
directory of the target DataStage Engine host where those tests actually ran. In the context of a running CI pipeline, the usual practice would be to have steps later on that retrieve the test result JUnit files from the DataStage Engine host and combine them with any JUnit files that had been written to the -reports
path, thereby producing a complete picture of the outcomes of the whole suite of tests attempted during that pipeline run.
The name of each JUnit file will be the same as the Job under test (e.g. Job MY_JOB_ABC
will produce a JUnit file named MY_JOB_ABC.xml
)
Most DataStage teams want their CI pipeline to halt when any test fails, either due to a failure to execute or when producing a test result of “failed”. If you don’t want these test failure events to halt your pipeline, add the -ignore-test-failures
switch to your command syntax.
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.
Syntax
Example
C:\> mettleci unittest test ^
-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 "C:\MettleCI\cache\test1-engn.datamigrators.io\my_project"
MettleCI Command Line (build 128)
(C) 2018-2022 Data Migrators Pty Ltd
Loading Unit Test Specifications from 'unittest'
Reading test1-engn.datamigrators.io/my_project
Attempting to identify changes with 1 working threads.
Inspecting DataStage assets for changes...
* Check test1-engn.datamigrators.io/my_project/Jobs/Transform/TR_ORDERS.pjb - COMPLETED
Change identification complete
Executing Tests with 4 concurrent jobs...
* Test TR_ORDERS/TR_ORDERS - SKIPPED
Updating incremental state...
Attempting to identify last change with 1 working threads.
Inspecting DataStage assets for last change...
* Check test1-engn.datamigrators.io/my_project/Jobs/Transform/TR_ORDERS.pjb - COMPLETED
Last change identification complete
Test execution completed successfully.
C:\>
Related content
© 2015-2024 Data Migrators Pty Ltd.