Synchronizing Test Case hierarchies
Last updated
Was this helpful?
Last updated
Was this helpful?
Besides and to Jira Test Cases, SpecSync can also help you to organize the remote Test Cases into hierarchical structures.
The Test Case hierarchy synchronization is only available to SpecSync for Azure DevOps currently. The feature will be available for SpecSync for Jira soon.
In SpecSync a Test Case hierarchy is a configured set of rules that defines a hierarchical structure for the Test Cases. The hierarchy defines several nodes, that might contain synchronized Test Cases.
SpecSync will take care of
Creating the hierarchy nodes
Adding the Test Cases to the hierarchy nodes according to the configured rules
Moving the Test Cases between hierarchy nodes when the rules conditions change (e.g. scenario is moved to another feature file)
Removing the Test Case from the hierarchy node if it is detected to be removed (requires a configured ).
Within one hierarchy each synchronized Test Case is included only once, but you can define multiple hierarchies. The hierarchy nodes might contain Test Cases that are not synchronized by SpecSync. These Test Cases have to be added to the hierarchy node manually, but SpecSync will not remove them during synchronization.
You can configure the hierarchies based on different commonly used rule-sets by choosing a hierarchy type. For example the following configuration defines a hierarchy that is based on the folder structure of the local test case documents. I.e. every folder and sub-folder becomes a hierarchy node.
The following configuration defines a hierarchy named folder-hierarchy
based on the folders and sub-folders of the files and includes all local test cases to the defined nodes that does not have an @ignore
tag.
folders
foldersAndFiles
foldersAndDocumentNames
levels
tag
single
custom
Regardless of the chosen hierarchy type there are some common settings that can be used.
name
: The name of the hierarchy is an identifier that can be used to refer to the hierarchy for other features (e.g. for publishing test results to that hierarchy). If no name is specified the name default
is used. The name has to be unique among the defined hierarchies and it is mandatory when multiple hierarchies are specified.
type
: Specifies the type of the hierarchy. It is mandatory and has to be set to one of the available hierarchy types from the table above.
root
: Specifies the root location in Jira, where the hierarchy should be mapped to. The root location specified here will be mapped to the root of the hierarchy.
ignoreAdditionalNodes
: By default SpecSync generates a warning if the hierarchy in Jira contains additional nodes (nodes that are not defined by the hierarchy). If such additional nodes are required, it is recommended to set this setting to true
to avoid unnecessary warnings.
disableUnderscoreTransformation
: The _
character in the matched node names are automatically transformed to space by default. This behavior can be disabled by setting the disableUnderscoreTransformation
hierarchy setting to true
. This setting can be used for levels
and tag
hierarchy types.
folders
, foldersAndFiles
and foldersAndDocumentNames
hierarchy typesThe folders
, foldersAndFiles
and foldersAndDocumentNames
hierarchy types define a hierarchy based on the source documents of the local test cases.
The source documents are usually arranged into a logical folder and file structure that is also useful to maintain in Jira.
All three types uses the folders and sub-folders of the source documents (e.g. feature files) as a core structure, but foldersAndFiles
and foldersAndDocumentNames
also defines nodes based on the source documents (e.g. feature files) as well.
Let's assume the following local test case structure. The SpecSync configuration root folder is the folder that contains the specsync.json
configuration file.
Choosing the folders
hierarchy type would generate the following hierarchy structure from the local test case structure above.
Choosing the foldersAndFiles
hierarchy type would define nodes from the files as well.
Choosing the foldersAndDocumentNames
hierarchy type almost identical to foldersAndFiles
except that it uses the name of the local test case document instead of the file name when available. For example for feature files it uses the feature name (the name you specify after the Feature:
prefix in the feature file).
Assuming the feature names of the example files are the same of the file names except of spaces, the hierarchy would look like the following.
In some cases the source documents are in a sub-folder of the SpecSync configuration root folder and you don't want to represent those folders in the hierarchy. Let's consider the following structure.
By default the src/features
folders would become part of the hierarchy. For example with folders
type, it would generate the following structure.
To avoid generating hierarchy nodes from src/features
, you can use the skipFolderPrefix
setting:
As a result, the following hierarchy is generated.
The skipFolderPrefix
setting can be used for folders
, foldersAndFiles
and foldersAndDocumentNames
hierarchy types.
levels
hierarchy typeThe levels
hierarchy type defines a hierarchy where the different levels correspond to a particular property or categorization of the test cases. This is useful when the levels of the desired structure is defined according to some aspects.
Let's assume we would like to build a hierarchy with three levels:
level 1: area (e.g. "Payments")
level 2: component (e.g. "FrontEnd")
level 3: test category (e.g. "Regression")
With this specification the Test Cases would be included to hierarchy nodes, like "Payments / FrontEnd / Regression".
Consider the following feature file.
The folder of the feature file (Payments
), the tags of the scenarios and the tags "inherited" from the Feature
and Rule
headers define the aspects of the test cases that we would like to use:
Scenario #1: Card payment is started
Area: Payments
Component: FrontEnd
Category: Smoke
Scenario #2: Card payment is successful
Area: Payments
Component: FrontEnd
Category: Regression
Scenario #3: Card payment is added to transaction log
Area: Payments
Component: BackEnd
Category: Regression
The following hierarchy configuration can be used to define the hierarchy with the "area", "component" and "test category" levels.
Synchronizing the feature file above would generate the following hierarchy.
When a level is defined with a wildcard match the hierarchy node name will use the value that has matched to the wildcard. The default behavior can be changed by specifying the name
level setting.
Let's say we would like to define the second level as FrontEnd Category
and BackEnd Category
instead of FrontEnd
and BackEnd
. This can be achieved by the following configuration.
In the name
level setting, the placeholder {1}
refers to the first wildcard, {2}
to the second wildcard (if present), and so on.
With this configuration, the generated hierarchy would become:
Ideally the value for each level can be detected based on the source path and the tags. In some cases some cases the scenarios are classified to a "default" category. For example the team may decide that if the scenario has no @component:xxx
tag, it should belong to the "General" component. They might also decide to just include these Test Cases to the parent hierarchy node.
SpecSync provides multiple options to handle this situation by specifying the onNotMatching
level setting. For example the following configuration uses a "General" component if the @component:xxx
tag is missing.
The following table contains the possible values for the onNotMatching
level setting. The default is ignore
for top level and skipLevel
for the other levels.
ignore
The Test Case is ignored and will not be included to this hierarchy. In the example above, if @component:xxx
tag is missing the Test Case would not be included in the hierarchy.
skipLevel
The non-matching level is skipped, so all levels below would be promoted by one. In the example above, if @component:xxx
tag is missing the Test Case would be included in a node like "Payments / Smoke".
includeToParent
The Test Case is included to the hierarchy node of the previous (parent) level node but the remaining levels are not processed. In the example above, if @component:xxx
tag is missing the Test Case would be included in the "Payments" node, regardless of whether it has @smoke
tag.
customName
A custom name is used instead that has to be specified using the nameForNotMatching
level setting. In the example above, if @component:xxx
tag is missing a "General" component level can be used instead.
tag
hierarchy typeThe tag
hierarchy type defines the hierarchy based on the hierarchy node paths specified using tags of a specified tag prefix.
Consider the following feature file.
The scenarios in the example above are tagged with a @suite:xxx
tag that specifies the hierarchy node path.
The following hierarchy configuration can be used to define this hierarchy.
Synchronizing the feature file above with this configuration would generate the following hierarchy.
single
hierarchy typeThe single
hierarchy type defines a hierarchy with a single node and all Test Cases that match to the optionally defined condition are included to that node.
The following configuration defines a hierarchy with a single "BDD Scenarios" node and includes all synchronized test cases that does not have an @ignore
tag.
custom
hierarchy typeThe custom
hierarchy type defines a hierarchy by configuring each node separately. For each node you can specify the node name or path and a condition that specifies which Test Cases should be included in that node. The test case will be included to the first node with a matching condition.
Consider the following feature file.
Synchronizing the feature file above with this configuration would generate the following hierarchy.
The third configured node ("Generic") does not have a condition, so it will include all Test Cases that have not been included by the conditions of the prior nodes. This means that if there is an additional scenario that is not within the Features/Payments/
folder or does not have neither a @smoke
nor a @regression
tag, it will be included here.
This feature description describes the usage of this feature. You can also check the reference guide of the .
The following table contains an overview of the supported hierarchy types. The sections below contain further details for the different types. The can be used for each hierarchy type.
Defines the hierarchy based on the folders and sub-folders of the local test case documents (e.g. feature files). Each node will contain the local test cases (scenarios) of every document that is located directly in the related folder. See details .
Defines the hierarchy based on the folders, sub-folders and file names of the local test case documents (e.g. feature files). The file name extension is omitted. Each node will contain the test cases of the related local test case document. See details .
Similar to foldersAndFiles
, but for the leaf nodes, it uses the name of the local test case document instead of the file name when available. For example for feature files it uses the feature name (the name you specify after the Feature:
prefix in the feature file). See details .
Defines a hierarchy where the different levels correspond to a particular property of the test cases. E.g. the top level is defined by the area of the test: "Payment", "Inventory", etc; and the second level is defined by the test type: "UI", "API", etc. The Test Cases will be included in nodes, like "Payment / API". See details .
The hierarchy nodes are defined by tags with a prefix, e.g. @suite:Payment/API
. See details .
Defines a hierarchy with a single node and all Test Cases that match to the optionally defined condition are included to that node. See details .
Specifies a hierarchy by specifying each node with a condition that defines which test case should be included to that node. The test case will be included to the first node with a matching condition. See details .
condition
: A to specify which test cases should be included to this hierarchy. By default all synchronized Test Cases is included.
If the files are not directly in the SpecSync configuration root folder, but in a sub-folder, you can consider using the skipFolderPrefix
setting, see details .
The <root>
node can be mapped to a root location in Jira, see for details.
In some cases a particular aspect cannot be detected (e.g. the scenario has neither @regression
nor @smoke
tag). You can configure how SpecSync should handle this case with the onNotMatching
and the nameForNotMatching
level settings. See details .
The levels can be specified with conditions similar to the ones that are used for .
The following configuration defines a hierarchy similar to the example we defined using the .