-
Notifications
You must be signed in to change notification settings - Fork 0
/
result.go
60 lines (47 loc) · 2.12 KB
/
result.go
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
// Copyright 2015 ThoughtWorks, Inc.
// This file is part of Gauge.
// Gauge is free software: you can redistribute it and/or modify
// it under the terms of the GNU General Public License as published by
// the Free Software Foundation, either version 3 of the License, or
// (at your option) any later version.
// Gauge is distributed in the hope that it will be useful,
// but WITHOUT ANY WARRANTY; without even the implied warranty of
// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
// GNU General Public License for more details.
// You should have received a copy of the GNU General Public License
// along with Gauge. If not, see <http://www.gnu.org/licenses/>.
package result
import "github.com/getgauge/gauge/gauge_messages"
// Result represents execution result
type Result interface {
GetPreHook() []*gauge_messages.ProtoHookFailure
GetPostHook() []*gauge_messages.ProtoHookFailure
GetFailed() bool
AddPreHook(...*gauge_messages.ProtoHookFailure)
AddPostHook(...*gauge_messages.ProtoHookFailure)
SetFailure()
Item() interface{}
ExecTime() int64
}
// ExecTimeTracker is an interface for tracking execution time
type ExecTimeTracker interface {
AddExecTime(int64)
}
// GetProtoHookFailure returns the failure result of hook execution
func GetProtoHookFailure(executionResult *gauge_messages.ProtoExecutionResult) *(gauge_messages.ProtoHookFailure) {
return &gauge_messages.ProtoHookFailure{StackTrace: executionResult.StackTrace, ErrorMessage: executionResult.ErrorMessage, FailureScreenshot: executionResult.ScreenShot, TableRowIndex: -1}
}
// AddPreHook adds the before hook execution result to the actual result object
func AddPreHook(result Result, executionResult *gauge_messages.ProtoExecutionResult) {
if executionResult.GetFailed() {
result.AddPreHook(GetProtoHookFailure(executionResult))
result.SetFailure()
}
}
// AddPostHook adds the after hook execution result to the actual result object
func AddPostHook(result Result, executionResult *gauge_messages.ProtoExecutionResult) {
if executionResult.GetFailed() {
result.AddPostHook(GetProtoHookFailure(executionResult))
result.SetFailure()
}
}