In the following documentation, the OpenText Core Software Delivery Platform and OpenText Software Delivery Management will collectively be referred to as 'the product'.
This is a command-line tool desinged to convert a list of test details received from the product to a format accepted by common frameworks. The tool allows defining custom conversion flow for other frameworks that are not supported by default.
- 1. Introduction
- 2. Table of Contents
- 3. Description
- 4. Getting Started
- 5. Custom Framework
- 6. Change log
The tool supports the following test frameworks out-of-the-box, as well as custom configurations for unsupported frameworks:
- Cucumber
- Cucumber with BDD Scenario
- JUnit
- Maven Surefire
- TestNG (Selenium)
- Custom (define your custom framework configuration - see more)
The tool have been released as a NPX command: @opentext/sdp-sdm-tests-to-run-conversion
Run the following command to convert the value of the --testsToRun
parameter received from the product to a format specified by the --framework
parameter.
npx @opentext/sdp-sdm-tests-to-run-conversion --framework="<framework_name>" --testsToRun="<test_definitions>" [--customFramework="<json_format_rules>"]
--testsToRun
- a list of automated tests to run, usualy received from the product.--framework
- the framework to which the--testsToRun
parameter will be converted. Available options are:- JUnit:
junit
- Maven Surefire:
mvnSurefire
- TestNG (Selenium):
testNG
- Cucumber:
cucumber
- Cucumber - BDD scenario:
bddScenario
- Custom framework:
custom
- JUnit:
--customFramework
(optional) - a JSON object serialized to string which contains the format rules used for conversion. To configure a custom framework see the section 5. Custom Framework.--logLevel
(optional) - the level to log at. The available options are:0
- Disabled1
- Debug2
- Trace3
- Info4
- Warn5
- Error
Caution
The logLevel
parameter should only be used while debugging. Remove or set it to 0
if you're not debugging this tool.
This example workflow demonstrates how to integrate a test conversion tool (@opentext/sdp-sdm-tests-to-run-conversion
) into a GitHub Actions pipeline to determine and execute specific tests dynamically. In the following example, the workflow will run some automated tests using the Maven Surefire framework.
-
Convert
testsToRun
Parameter:- Use the tool as an NPX command to process the
testsToRun
input. - The tool outputs a list of test identifiers.
- The output is stored in an environment variable for later use.
- Use the tool as an NPX command to process the
-
Set Up Java:
- Use the
setup-java
action to prepare the environment with JDK 21.
- Use the
-
Run Tests:
- Use Maven to run the tests specified by the conversion tool output.
jobs:
build:
runs-on: ubuntu-latest
steps:
# Checkout code
- name: Checkout code
uses: actions/checkout@v4
# Step 1: Convert testsToRun parameter
- name: Convert testsToRun parameter
id: convert_tests
run: |
# Run the npx command and capture its output
output=$(npx @opentext/sdp-sdm-tests-to-run-conversion --framework="junit" --testsToRun="${{ github.event.inputs.testsToRun }}" --logLevel=0)
# Save the output to an environment variable
echo "converted_tests=$output" >> $GITHUB_ENV
echo "::set-output name=converted_tests::$output"
# Step 2: Set up Java environment
- name: Set up JDK 21
uses: actions/setup-java@v4
with:
distribution: "temurin"
java-version: "21"
# Step 3: Run the tests from the converted list
- name: Run JUnit Tests
run: mvn test -Dtest="$converted_tests"
If your framework isn't supported by default, you can define a custom configuration. Use the --customFramework
parameter in the command call to provide the configuration, specifying a pattern to convert the testsToRun
value into the required format for your framework.
To configure a custom framework, you'll need to provide a JSON object with specific keys. At a minimum, the following two keys are required:
testPattern
: Defines the structure of the tests based on Package, Class name, and Test name.testDelimiter
: A character or string that separates tests in the testsToRun parameter.
In the custom configuration, you can define a pattern using the following placeholders:
$package
: Represents the package name of the test.$class
: Represents the class name of the test.$testName
: Represents the name of the individual test.
For example, if you want to generate a JUnit report structured like this:
"com.example:Calculator#addTwoNumbers, com.example:Calculator#subtractTwoNumbers"
You would define your custom framework JSON like this:
{
"testPattern": "$package:$class#$testName",
"testDelimiter": ", "
}
You can also include the following optional keys:
-
prefix
andsuffix
: Strings that will be added at the beginning and end of the test names. -
replacements
: An array of replacement objects that modify string values for package, class name, and test name.
The replacement objects can be of various types:
replaceString
: Replaces every occurrence of a specified string.
{
"type": "replaceString",
"target": "$class",
"string": "<stringToReplace>",
"replacement": "<replacementString>"
}
replaceRegex
: Replaces every occurrence of a regex pattern.
{
"type": "replaceRegex",
"target": "$class",
"regex": "<regexToReplace>",
"replacement": "<replacementString>"
}
replaceRegexFirst
: Replaces only the first occurrence of a regex pattern.
{
"type": "replaceRegexFirst",
"target": "$class",
"regex": "<regexToReplace>",
"replacement": "<replacementString>"
}
notLatinAndDigitToOctal
: Converts non-latin or digit characters to octal representation.
{
"type": "notLatinAndDigitToOctal",
"target": "$class"
}
joinString
: Adds a prefix and/or suffix to the target.
{
"type": "joinString",
"target": "$class",
"suffix": "<suffixToAdd>",
"prefix": "<prefixToAdd>"
}
toUpperCase
andtoLowerCase
: Converts the target to upper or lower case, respectively.
{
"type": "toUpperCase",
"target": "$class"
}
allowDuplication
: A boolean value (default is true) that allows or disallows duplicate values in the testsToRun parameter.
{
"allowDuplication": true
}
Using the same JUnit report structure, if you need to adjust the format of the class name and include additional transformations:
{
"testPattern": "$package:$class#$testName",
"testDelimiter": ", ",
"replacements": [
{
"type": "replaceString",
"target": "$class",
"string": ".",
"replacement": "\\"
},
{
"type": "replaceRegex",
"target": "$class",
"regex": "(\\b\\\\\\b)(?!.*\\1)",
"replacement": ".mytest:"
}
]
}
Note
When specifying escape characters in the JSON, ensure that each escape character is doubled (e.g., \\ instead of \).
- Converts the
testsToRun
parameter to a format accepted by a specific framework.