parse

package module
v0.0.0-...-2ba0901 Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: Jan 3, 2017 License: Apache-2.0 Imports: 4 Imported by: 4

README

tugbot-parse

CircleCI codecov Go Report Card

tugbot-parse is a small utility for converting a JUnit XML into JSON.

##How to install:

go get github.com/gaia-docker/tugbot-parses

##How to use

###Parsing a JUnit XML

import "github.com/gaia-docker/tugbot-parse"

testSet, err := ToTestSet([]byte(`
	<testsuite name="Mocha Tests" tests="1" failures="1" errors="1" skipped="0" timestamp="Mon, 25 Jul 2016 14:44:37 GMT" time="0.149">
		<testcase classname="Functional tests - voting" name="open ui and check title" time="0"><failure>expected -1 to be above -1
		AssertionError: expected -1 to be above -1
		   at Assertion.assertAbove (node_modules/chai/lib/chai/core/assertions.js:571:12)
		   at Assertion.ctx.(anonymous function) [as above] (node_modules/chai/lib/chai/utils/addMethod.js:41:25)
		   at Request._callback (specs/functional/vote-page-test.js:27:97)
		   at Request.self.callback (node_modules/request/request.js:187:22)
		   at Request.&lt;anonymous&gt; (node_modules/request/request.js:1044:10)
		   at IncomingMessage.&lt;anonymous&gt; (node_modules/request/request.js:965:12)
		   at endReadableNT (_stream_readable.js:913:12)
		   at _combinedTickCallback (internal/process/next_tick.js:74:11)
		   at process._tickCallback (internal/process/next_tick.js:98:9)</failure>
   		</testcase>
	</testsuite>`))
if err != nil {
		panic(err)
}
fmt.Print(testSet)

Documentation

Index

Constants

View Source
const (
	Passed  = "Passed"
	Skipped = "Skipped"
	Failed  = "Failed"
	Error   = "Error"
)

Test Status

Variables

This section is empty.

Functions

This section is empty.

Types

type AnalyticsTest

type AnalyticsTest struct {
	Name          string
	Time          FloatNumber
	Failure       string
	Error         string
	Status        string
	NumericStatus int
	TestSet       AnalyticsTestSet
}

func ToAnalyticsTests

func ToAnalyticsTests(junit []byte) ([]AnalyticsTest, error)

type AnalyticsTestSet

type AnalyticsTestSet struct {
	Name     string
	Time     FloatNumber
	Total    int
	Failures int
	Errors   int
	Skipped  int
}

type FloatNumber

type FloatNumber float64

Make sure that when we marshal there will always be a precise point after the number (e.g. - 1.000)

func (FloatNumber) MarshalJSON

func (n FloatNumber) MarshalJSON() ([]byte, error)

type JunitTestCase

type JunitTestCase struct {
	Name    string   `xml:"name,attr"`
	Time    string   `xml:"time,attr"`
	Failure string   `xml:"failure"`
	Skipped xml.Name `xml:"skipped"`
	Error   string   `xml:"error"`
}

type JunitTestSuite

type JunitTestSuite struct {
	Name      string          `xml:"name,attr"`
	Time      string          `xml:"time,attr"`
	Total     string          `xml:"tests,attr"`
	Failures  string          `xml:"failures,attr"`
	Errors    string          `xml:"errors,attr"`
	Skipped   string          `xml:"skipped,attr"`
	TestCases []JunitTestCase `xml:"testcase"`
}

type Test

type Test struct {
	Name    string
	Status  string
	Time    float64
	Failure string
	Error   string
}

type TestSet

type TestSet struct {
	Name     string
	Time     float64
	Total    int
	Failures int
	Errors   int
	Skipped  int
	Tests    []Test
}

func ToTestSet

func ToTestSet(junit []byte) (*TestSet, error)

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL