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

Support for nested test suite output ? #59

Open
mohanraj-r opened this issue May 14, 2018 · 3 comments
Open

Support for nested test suite output ? #59

mohanraj-r opened this issue May 14, 2018 · 3 comments

Comments

@mohanraj-r
Copy link

mohanraj-r commented May 14, 2018

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.

@tebeka
Copy link
Owner

tebeka commented May 15, 2018

Hi. Will have a look Thursday.

@mohanraj-r
Copy link
Author

@tebeka wondering if you had a chance to look into this

@tebeka
Copy link
Owner

tebeka commented May 19, 2018

I guess it's possible and will require some code changes. Sadly I'm super busy right now and don't have time to do these changes. I'll probably have some free time mid-June.

I'd love to get a patch if you're interested, can mentor to some degree.

Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants