Skip to main content

Export TestPartner run into xml with xsl

TestPartner run results can be exported using command line, tpexport, or via File|Export from with TestPartner itself.

Another way of exporting run results is via TestPartner.TLB automation. The beauty with TestPartner.TLB is that you can export with it the xsl.

See below for the code.
Option Explicit
Sub TestTPResultDump()
    Dim t As New TPApp
    Dim pCount As Integer
    Dim p As Integer
    Dim sCount As Integer
    Dim sName As String
    Dim tp2 As TestPartner.TPProject2


    t.Login "admin", "admin", "TestPartner_SQL", 1

    pCount = t.Projects.Count

    For p = 1 To pCount
        If t.Projects.Item(p).Name = "ScratchProject" Then
            Debug.Print t.Projects.Item(p).Name
            Set tp2 = t.Projects.Item(p)
            Dim rc As Integer
            For rc = 1 To tp2.Results.Count
                If tp2.Results.Item(rc).Name = "scratch2" Then
                    Debug.Print tp2.Results.Item(rc).Description
                    Debug.Print tp2.Results.Item(rc).Name
                    Debug.Print tp2.Results.Item(rc).LastModifiedBy
                    Dim v As Long
                    v = tp2.Results.Item(rc).CurrentVersion
                    Dim rr As TestPartner.TPResult
                    Set rr = tp2.Results.Item(rc)
                    rr.Open (v)
                    Debug.Print rr.GetXML(v, v, "d:\test.xml")
                    Call rr.GetXML(v, 1, "D:\test.xml", "D:\test.xsl")
    
                    Dim sXLST As String
                    Dim fXLST As Scripting.File
                    
                    Debug.Print rr.GetXSLT(1, sXLST)
                    'Debug.Print sXLST
                    Dim fso As Scripting.FileSystemObject
                    Dim ts As Scripting.TextStream
                    Set fso = New Scripting.FileSystemObject
                    Set ts = fso.OpenTextFile("D:\test.xsl", ForWriting, True, TristateTrue)
                    ts.Write sXLST
                    ts.Close
                    Set ts = Nothing
                    Set fso = Nothing
                End If
            Next rc
            'tp2.Results.Count
        End If

    Next p
End Sub

Note that you need reference to TestPartner(TestPartner.TLB) and Microsoft Scripting Runtime for the above code snippets to work.

See below for the location of the type library:

















~ts

Comments

Anonymous said…
hello,

what is TestPartner.tlb ?
This is a Testpartner specific type library. See my main post again as I added screen capture of the file location.
Anonymous said…
Is there a way to also include the Pass\Fail result in the xml dump of the run?

Also, where can I find more information on the TestPartner API.
I didn't check the xml export closely but if my recollection is correct it should have the pass/fail information.

And TestPartner.tlb is internal to TestPartner and undocumented. So beware, you will not get support from the company if you use it.
Yash Ganthe said…
Do you have an XSL which converts the cryptic result xml file to a neat format. Can you please chare it with me?
Yash Ganthe said…
Teh results xml file appears to be very complex. Do you have an XSL which can convert it to a neat format? Can you please share it if yes?
Anonymous said…
i have try like you comment and it doesn't work ??

no result exported

Popular posts from this blog

Error! Could not locate dkms.conf file install VirtualBox 4.1.8 on Ubuntu 11.10

Tried to update my Ubuntu host today and it did pickup that new version of VirtualBox is available (4.1.8). All other packages installed properly except that VirtualBox installation was complaining about missing dkms.conf file, see error message below. $: sudo /etc/init.d/vboxdrv setup * Stopping VirtualBox kernel modules [ OK ] * Uninstalling old VirtualBox DKMS kernel modules Error! Could not locate dkms.conf file. File: does not exist. [ OK ] * Trying to register the VirtualBox kernel modules using DKMS [ OK ] * Starting VirtualBox kernel modules [ OK ] Though it looks like installation was fine but I am concerned about its effects to VirtualBox functionality. To fix this, do: $: cd /var/lib/dkms/vboxhost $: sudo rm -r 4.1.4 $: sudo /etc/init.d/vboxdrv setup Of course you have to re

The following add-ins could not be started MonoDevelop.GnomePlatform

Installing MonoDevelop in OpenSUSE 12.2 from its repository was very easy. When running it for the first time though I got the message: The following add-ins could not be started: The root of the trace shows MonoDevelop.GnomePlatform,2.8 A quick search shows that MonoDevelop depends on libgnomeui . This should have been part of dependencies when installing the application but well.... Below is the screen shot of the error message. References: http://software.1713.n2.nabble.com/MonoDevelop-and-openSUSE-12-1-td7462957.html [2013/04/09] - Same issue observed in OpenSUSE 12.3 and also the same fix. [2014/11/02] - Same issue observed in OpenSUSE 13.3, mondevelop 3.0.6 and the same fix.