Join 34,000+ subscribers and receive articles from our blog about software quality, testing, QA and security.
 

Test Cases with xml description in TestLink import to TestRail


#1

Hi all,

I’ve faced with an issue during migration from TestLink to TestRail.
Part of my cases in TestLink has XML description which is used by automation framework to run Automation Tests.

I’ve export test suite from Test Link to xml format and then transformed it using testlink2testrail script.

After that I found all XML descriptions were removed from new xml file.

I would be really appreciate if you could help with that issue.

Thank you.


#2

Hi Fedor,

Thanks for your posting. Is the XML description a custom field? The testlink2testrail script supports the TestLink standard fields but you can add additional fields by modifying the script. This requires some programming experience but the script is quite self-explanatory and we are also happy to help in case you have any questions. If the description field is a custom field, you could look into adding the same field on TestRail’s and then map both fields using a modified version of testlink2testrail. Would this work for you?

http://docs.gurock.com/testrail-userguide/howto-fields

Cheers,
Tobias


#3

I would be really appreciate it if you could provide example of modified testlink2testrail php script.

Thank you in advance.


#4

Hi Fedor,

The idea is to add support for an additional field by checking the case value in the TestLink export script and writing this to the TestRail XML output file. For example, for the summary field, this looks as follows:

if (isset($case->summary) && strlen(trim($case->summary)) > 0)
{    
    xml_write_html_tag($handle, 'summary', $case->summary);
}

Do you already use the Summary field for this or a different field in TestLink? If you use the Summary field, you can simply add this to TestRail under Administration > Customizations and the migration script would already work out of the box. In TestRail, you would need to a field of type Text with a system name of summary under Administration > Customizations:

http://docs.gurock.com/testrail-userguide/howto-fields

Cheers,
Tobias


#5

I am sorry, I am not familiar with PHP.
I would be really grateful if you could help me with that.

I get next format from testlink:
<node_order>3</node_order>294231


Summary-test

221XML_DESCRIPTION test

And I need next format in TestRail:
S36Auto-testTest CasesC4547testrail_1Test Case (Text)OtherMedium

testrail<xml_description>


</xml_description>


#6

Hi Fedor,

I’m not sure I understand. Do you use the standard Summary field of TestLink to store the XML data?

As mentioned, if you use the Summary field for this you can simply add this to TestRail under Administration > Customizations and the migration script would already work out of the box. In TestRail, you would need to a field of type Text with a system name of summary under Administration > Customizations:

Cheers,
Tobias


#7

Hi Tobias,

I am using another custom field in TestLink for xml description:
<|custom_fields>
<|custom_field>
<|name>XML_DESCRIPTION
<|value>
example
<|/value>
<|/custom_field>
<|/custom_fields>

And I want script to convert it to TestRail format:
<|custom>
<|xml_description>
example
<|/xml_description>
<|/custom>

That’s all.


#8

Hi Fedor,

I would suggest going through the list of custom field per case and then check for the “name” of the field. This could look as follows:

if (isset($case->custom_fields))
{
    foreach ($case->custom_fields->custom_field as $field)
    {
        if ($field->name == 'XML_DESCRIPTION')
        {
            xml_write_html_tag($handle, 'xml_description', $field->value);
        }
    }
}

I hope this helps!

Cheers,
Tobias


#9

Thank you.

It almost works.

But now all xml tags are removed from XML_Description field.

How I can convert that field to get it the same in new file if that field contains xml tags in original file?

Thank you.


#10

Hi Fedor,

Ah yes, you would need to modify xml_write_html_tag for this and maybe add an extra parameter to avoid stripping the HTML/XML tags. You can also look into changing the formatting slightly so the XML would be rendered as pre-formatted (<pre>) text in TestRail. This requires adding 4 spaces before each line:

http://docs.gurock.com/testrail-userguide/userguide-editor#code_and_preformatted_text

Cheers,
Tobias


#11

Thank you.

Just sharing my workaround for others:
if (isset($case->custom_fields))
{
foreach ($case->custom_fields->custom_field as $field)
{
if ($field->name == ‘XML_DESCRIPTION’)
{
xml_write_html_tag($handle, ‘xml_description’, xml_escape( (string) $field->value));
}
}
}


#12

Thanks for sharing this and great to hear that you found a solution :slight_smile:

Cheers,
Tobias