Skip to content
This repository was archived by the owner on Nov 20, 2019. It is now read-only.

Support for nested test suite output ? #59

@mohanraj-r

Description

@mohanraj-r

I am using "github.com/tebeka/go2xunit/lib" to build junit xml output for a custom go tool.
I am wondering if its possible to build nested test output e.g. as in xunit-viewer/complete_multi_suites.xml

e.g

 <!-- nested suites -->
        <testsuite name="parent">
            <testcase name="parent test"></testcase>
            <testsuite name="child one">
                <testcase name="child one test"></testcase>
            </testsuite>
            <testsuite name="child two">
                <testcase name="child two test"></testcase>
                <testsuite name="child of child two">
                    <testcase name="child of child two test"></testcase>
                </testsuite>
            </testsuite>
        </testsuite>

The basic usage of the lib in my tool is

suite := &xunit.Suite{Name: "foo"}

	for _, r := range results {
                 t := &xunit.Test{
				Name:   r.Name,
				Status:  r.Status,
				Message: r.GetDebugInfo(),
			}
			suite.Tests = append(suite.Tests, t)
        }

xunit.WriteXML(xunit.Suites{suite}, out, xunit.XUnitTemplate, time.Now())

But the results have 3 level nested hierarchy of data (not shown in the sample above for simplification) and distinctly different categories. I would like to use the nested structure of xunit testsuite to produce a better nested output than the plain single level output. But not sure if its possible using "go2xunit/lib"

For this to be possible I guess the Suite type should have a pointer to itself ?
I see that the Test type has an unexported field isParentTest - I was able to trace out how this field is used vaguely - but not sure if this would be helpful here esp since its not exported.

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions