1

Topic: Importing test cases from TestLink

Has anyone converted test cases from TestLink XML to the TestRail format?

2

Re: Importing test cases from TestLink

Already answered this via email, but to let other readers know as well:

We currently do not have a conversion script available but are looking into providing tools to convert and import other formats directly into TestRail.

Regards,
Tobias

3

Re: Importing test cases from TestLink

I created an XSLT Transform and a quick perl script that works fairly well. You can run them from bash as follows:

    xsltproc tl2tr.xslt all_testsuites.xml  | tr "\n" " " | ./transform.pl| xmllint --format - > import.xml

tl2tr.xslt

<?xml version="1.0"?>
<xsl:stylesheet version="1.0"
                xmlns:xsl="http://www.w3.org/1999/XSL/Transform">
<xsl:template match="/">
  <xsl:for-each select="testsuite">
    <xsl:call-template name="sections" />
  </xsl:for-each>
</xsl:template>
<xsl:template name="sections">
  <xsl:if test="count(testsuite) &gt; 0">
  <sections>
    <xsl:for-each select="testsuite">
      <section>
        <name><xsl:value-of select="@name" /></name>
        <xsl:if test="count(testcase) &gt; 0">
        <cases>
          <xsl:for-each select="testcase">
            <xsl:call-template name="testcase" />
          </xsl:for-each>
        </cases>
        </xsl:if>
        <xsl:call-template name="sections" />
      </section>
    </xsl:for-each>
  </sections>
  </xsl:if>
</xsl:template>
<xsl:template name="testcase">
  <case>
    <title><xsl:value-of select="@name" /></title>
    <type></type>
    <priority></priority>
    <estimate></estimate>
    <milestone></milestone>
    <preconds><xsl:value-of select="summary" /></preconds>
    <steps><xsl:value-of select="steps" /></steps>
    <expected><xsl:value-of select="expectedresults" /></expected>
  </case>
</xsl:template>
</xsl:stylesheet>

transform.pl
while(<>)
{
    # bulleted lists
    s/&lt;li&gt;/\n-/g;
    s/&lt;\/li&gt;//g;

    # kill all html
    s/&lt;\/?[a-z]+( .*?)?&gt;//g;
    print;
}

4

Re: Importing test cases from TestLink

Hi asm,

Thanks a lot for sharing your scripts, we really appreciate it. I will make sure to try your scripts today (and recommend them to other customers who want to migrate from TestLink). Thanks again!

Regards,
Tobias