Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

fix: SystemOutput in the PipelineTestCase #1697

Merged
merged 4 commits into from
Apr 13, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
50 changes: 28 additions & 22 deletions pipelines.go
Original file line number Diff line number Diff line change
Expand Up @@ -87,38 +87,44 @@ func (p Pipeline) String() string {

// PipelineTestReport contains a detailed report of a test run.
type PipelineTestReport struct {
TotalTime float64 `json:"total_time"`
TotalCount int `json:"total_count"`
SuccessCount int `json:"success_count"`
FailedCount int `json:"failed_count"`
SkippedCount int `json:"skipped_count"`
ErrorCount int `json:"error_count"`
TestSuites []*PipelineTestSuites `json:"test_suites"`
}

// PipelineTestSuites contains test suites results.
type PipelineTestSuites struct {
Name string `json:"name"`
TotalTime float64 `json:"total_time"`
TotalCount int `json:"total_count"`
SuccessCount int `json:"success_count"`
FailedCount int `json:"failed_count"`
SkippedCount int `json:"skipped_count"`
ErrorCount int `json:"error_count"`
TestSuites []PipelineTestSuites `json:"test_suites"`
}

// PipelineTestSuites contains test suites results.
type PipelineTestSuites struct {
Name string `json:"name"`
TotalTime float64 `json:"total_time"`
TotalCount int `json:"total_count"`
SuccessCount int `json:"success_count"`
FailedCount int `json:"failed_count"`
SkippedCount int `json:"skipped_count"`
ErrorCount int `json:"error_count"`
TestCases []PipelineTestCases `json:"test_cases"`
TestCases []*PipelineTestCases `json:"test_cases"`
}

// PipelineTestCases contains test cases details.
type PipelineTestCases struct {
Status string `json:"status"`
Name string `json:"name"`
Classname string `json:"classname"`
File string `json:"file"`
ExecutionTime float64 `json:"execution_time"`
SystemOutput string `json:"system_output"`
StackTrace string `json:"stack_trace"`
AttachmentURL string `json:"attachment_url"`
RecentFailures RecentFailures `json:"recent_failures"`
Status string `json:"status"`
Name string `json:"name"`
Classname string `json:"classname"`
File string `json:"file"`
ExecutionTime float64 `json:"execution_time"`
SystemOutput *SystemOutput `json:"system_output"`
StackTrace string `json:"stack_trace"`
AttachmentURL string `json:"attachment_url"`
RecentFailures *RecentFailures `json:"recent_failures"`
}

// SystemOutput contains information about test cases when it fails.
type SystemOutput struct {
GaikwadPratik marked this conversation as resolved.
Show resolved Hide resolved
Type string `json:"type"`
Message string `json:"message"`
}

// RecentFailures contains failures count for the project's default branch.
Expand Down
56 changes: 19 additions & 37 deletions pipelines_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -100,63 +100,52 @@ func TestGetPipelineTestReport(t *testing.T) {
TotalTime: 61.502,
TotalCount: 9,
SuccessCount: 5,
FailedCount: 0,
SkippedCount: 0,
ErrorCount: 4,
TestSuites: []PipelineTestSuites{
TestSuites: []*PipelineTestSuites{
{
Name: "Failing",
TotalTime: 60.494,
TotalCount: 8,
SuccessCount: 4,
FailedCount: 0,
SkippedCount: 0,
ErrorCount: 4,
TestCases: []PipelineTestCases{
TestCases: []*PipelineTestCases{
{
Status: "error",
Name: "Error testcase 1",
Classname: "MyClassOne",
File: "/path/file.ext",
ExecutionTime: 19.987,
SystemOutput: "output message\n\noutput message 2",
SystemOutput: &SystemOutput{
Type: "failure",
Message: "Failed test",
},
StackTrace: "java.lang.Exception: Stack trace\nat java.base/java.lang.Thread.dumpStack(Thread.java:1383)",
AttachmentURL: "http://foo.bar",
RecentFailures: RecentFailures{
RecentFailures: &RecentFailures{
Count: 10,
BaseBranch: "master",
},
},
{
Status: "error",
Name: "Error testcase 2",
Classname: "MyClass",
File: "",
ExecutionTime: 19.984,
SystemOutput: "",
StackTrace: "",
AttachmentURL: "",
RecentFailures: RecentFailures{},
},
{
Status: "error",
Name: "Error testcase 3",
Name: "Error testcase 2",
Classname: "MyClass",
File: "",
ExecutionTime: 0.0,
SystemOutput: "Undefined message",
StackTrace: "",
AttachmentURL: "",
ExecutionTime: 19.984,
},
{
Status: "error",
Name: "Error testcase 3",
Classname: "MyClass",
SystemOutput: &SystemOutput{
Type: "failure",
Message: "Failed test",
},
},
{
Status: "success",
Name: "Succes full testcase",
Classname: "MyClass",
File: "",
ExecutionTime: 19.7799999999999985,
SystemOutput: "",
StackTrace: "",
AttachmentURL: "",
},
},
},
Expand All @@ -165,18 +154,11 @@ func TestGetPipelineTestReport(t *testing.T) {
TotalTime: 1.008,
TotalCount: 1,
SuccessCount: 1,
FailedCount: 0,
SkippedCount: 0,
ErrorCount: 0,
TestCases: []PipelineTestCases{{
TestCases: []*PipelineTestCases{{
Status: "success",
Name: "Succesfull testcase",
Classname: "MyClass",
File: "",
ExecutionTime: 1.008,
SystemOutput: "",
StackTrace: "",
AttachmentURL: "",
}},
},
},
Expand Down
10 changes: 8 additions & 2 deletions testdata/get_pipeline_testreport.json
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,10 @@
"classname": "MyClassOne",
"file": "/path/file.ext",
"execution_time": 19.987,
"system_output": "output message\n\noutput message 2",
"system_output": {
"type": "failure",
"message": "Failed test"
},
"stack_trace": "java.lang.Exception: Stack trace\nat java.base/java.lang.Thread.dumpStack(Thread.java:1383)",
"attachment_url": "http://foo.bar",
"recent_failures": {
Expand All @@ -47,7 +50,10 @@
"classname": "MyClass",
"file": null,
"execution_time": 0.0,
"system_output": "Undefined message"
"system_output": {
"type": "failure",
"message": "Failed test"
}
},
{
"status": "success",
Expand Down