func (self *XmlBuilder) getScenarioContent(result *gauge_messages.ProtoSpecResult, scenario *gauge_messages.ProtoScenario, ts *JUnitTestSuite) { testCase := JUnitTestCase{ Classname: result.GetProtoSpec().GetSpecHeading(), Name: scenario.GetScenarioHeading(), Time: formatTime(int(scenario.GetExecutionTime())), Failure: nil, } if scenario.GetFailed() { message, content := self.getFailure(scenario) testCase.Failure = &JUnitFailure{ Message: message, Type: message, Contents: content, } } else if scenario.GetSkipped() { testCase.SkipMessage = &JUnitSkipMessage{ Message: strings.Join(scenario.SkipErrors, "\n"), } } ts.TestCases = append(ts.TestCases, testCase) }
func (self *XmlBuilder) getTestSuite(result *gauge_messages.ProtoSpecResult, hostName string) JUnitTestSuite { now := time.Now() formattedNow := fmt.Sprintf(timeStampFormat, now.Year(), now.Month(), now.Day(), now.Hour(), now.Minute(), now.Second()) systemError := SystemErr{} if result.GetScenarioSkippedCount() > 0 { systemError.Contents = fmt.Sprintf("Validation failed, %d Scenarios were skipped.", result.GetScenarioSkippedCount()) } return JUnitTestSuite{ Id: int(self.currentId), Tests: int(result.GetScenarioCount()), Failures: int(result.GetScenarioFailedCount()), Time: formatTime(int(result.GetExecutionTime())), Timestamp: formattedNow, Name: result.GetProtoSpec().GetSpecHeading(), Errors: 0, Hostname: hostName, Package: result.GetProtoSpec().GetFileName(), Properties: []JUnitProperty{}, TestCases: []JUnitTestCase{}, SkippedTestCount: int(result.GetScenarioSkippedCount()), SystemOutput: SystemOut{}, SystemError: systemError, } }
func (self *XmlBuilder) getSpecContent(result *gauge_messages.ProtoSpecResult) { self.currentId += 1 hostName, err := os.Hostname() if err != nil { hostName = hostname } ts := self.getTestSuite(result, hostName) if result.GetProtoSpec().GetPreHookFailure() != nil || result.GetProtoSpec().GetPostHookFailure() != nil { ts.Failures += 1 } for _, test := range result.GetProtoSpec().GetItems() { if test.GetItemType() == gauge_messages.ProtoItem_Scenario { self.getScenarioContent(result, test.GetScenario(), &ts) } else if test.GetItemType() == gauge_messages.ProtoItem_TableDrivenScenario { self.getTableDrivenScenarioContent(result, test.GetTableDrivenScenario(), &ts) } } self.suites.Suites = append(self.suites.Suites, ts) }