fix snippet trailing space, missing event for test case finish
Этот коммит содержится в:
		
							родитель
							
								
									fb26a4d567
								
							
						
					
					
						коммит
						8d911a71f0
					
				
					 2 изменённых файлов: 39 добавлений и 15 удалений
				
			
		
							
								
								
									
										5
									
								
								fmt.go
									
										
									
									
									
								
							
							
						
						
									
										5
									
								
								fmt.go
									
										
									
									
									
								
							|  | @ -31,8 +31,9 @@ var undefinedSnippetsTpl = template.Must(template.New("snippets").Funcs(snippetH | ||||||
| 	return godog.ErrPending | 	return godog.ErrPending | ||||||
| } | } | ||||||
| 
 | 
 | ||||||
| {{end}}func FeatureContext(s *godog.Suite) { {{ range . }} | {{end}}func FeatureContext(s *godog.Suite) { {{- range . }} | ||||||
| 	s.Step({{ backticked .Expr }}, {{ .Method }}){{end}} | 	s.Step({{ backticked .Expr }}, {{ .Method }}) | ||||||
|  | {{- end}} | ||||||
| } | } | ||||||
| `)) | `)) | ||||||
| 
 | 
 | ||||||
|  |  | ||||||
|  | @ -47,8 +47,9 @@ type events struct { | ||||||
| 	// this is sadly not passed by gherkin nodes. | 	// this is sadly not passed by gherkin nodes. | ||||||
| 	// it restricts this formatter to run only in synchronous single | 	// it restricts this formatter to run only in synchronous single | ||||||
| 	// threaded execution. Unless running a copy of formatter for each feature | 	// threaded execution. Unless running a copy of formatter for each feature | ||||||
| 	path string | 	path         string | ||||||
| 	stat stepType // last step status, before skipped | 	stat         stepType // last step status, before skipped | ||||||
|  | 	outlineSteps int      // number of current outline scenario steps | ||||||
| } | } | ||||||
| 
 | 
 | ||||||
| func (f *events) event(ev interface{}) { | func (f *events) event(ev interface{}) { | ||||||
|  | @ -62,26 +63,46 @@ func (f *events) event(ev interface{}) { | ||||||
| func (f *events) Node(n interface{}) { | func (f *events) Node(n interface{}) { | ||||||
| 	f.basefmt.Node(n) | 	f.basefmt.Node(n) | ||||||
| 
 | 
 | ||||||
|  | 	var id string | ||||||
|  | 	var undefined bool | ||||||
| 	switch t := n.(type) { | 	switch t := n.(type) { | ||||||
| 	case *gherkin.Scenario: | 	case *gherkin.Scenario: | ||||||
| 		f.event(&struct { | 		id = fmt.Sprintf("%s:%d", f.path, t.Location.Line) | ||||||
| 			Event     string `json:"event"` | 		undefined = len(t.Steps) == 0 | ||||||
| 			Location  string `json:"location"` |  | ||||||
| 			Timestamp int64  `json:"timestamp"` |  | ||||||
| 		}{ |  | ||||||
| 			"TestCaseStarted", |  | ||||||
| 			fmt.Sprintf("%s:%d", f.path, t.Location.Line), |  | ||||||
| 			time.Now().UnixNano() / nanoSec, |  | ||||||
| 		}) |  | ||||||
| 	case *gherkin.TableRow: | 	case *gherkin.TableRow: | ||||||
|  | 		id = fmt.Sprintf("%s:%d", f.path, t.Location.Line) | ||||||
|  | 		undefined = f.outlineSteps == 0 | ||||||
|  | 	case *gherkin.ScenarioOutline: | ||||||
|  | 		f.outlineSteps = len(t.Steps) | ||||||
|  | 	} | ||||||
|  | 
 | ||||||
|  | 	if len(id) == 0 { | ||||||
|  | 		return | ||||||
|  | 	} | ||||||
|  | 
 | ||||||
|  | 	f.event(&struct { | ||||||
|  | 		Event     string `json:"event"` | ||||||
|  | 		Location  string `json:"location"` | ||||||
|  | 		Timestamp int64  `json:"timestamp"` | ||||||
|  | 	}{ | ||||||
|  | 		"TestCaseStarted", | ||||||
|  | 		id, | ||||||
|  | 		time.Now().UnixNano() / nanoSec, | ||||||
|  | 	}) | ||||||
|  | 
 | ||||||
|  | 	if undefined { | ||||||
|  | 		// @TODO: is status undefined or passed? when there are no steps | ||||||
|  | 		// for this scenario | ||||||
| 		f.event(&struct { | 		f.event(&struct { | ||||||
| 			Event     string `json:"event"` | 			Event     string `json:"event"` | ||||||
| 			Location  string `json:"location"` | 			Location  string `json:"location"` | ||||||
| 			Timestamp int64  `json:"timestamp"` | 			Timestamp int64  `json:"timestamp"` | ||||||
|  | 			Status    string `json:"status"` | ||||||
| 		}{ | 		}{ | ||||||
| 			"TestCaseStarted", | 			"TestCaseFinished", | ||||||
| 			fmt.Sprintf("%s:%d", f.path, t.Location.Line), | 			id, | ||||||
| 			time.Now().UnixNano() / nanoSec, | 			time.Now().UnixNano() / nanoSec, | ||||||
|  | 			"undefined", | ||||||
| 		}) | 		}) | ||||||
| 	} | 	} | ||||||
| } | } | ||||||
|  | @ -123,11 +144,13 @@ func (f *events) Summary() { | ||||||
| 		Status    string `json:"status"` | 		Status    string `json:"status"` | ||||||
| 		Timestamp int64  `json:"timestamp"` | 		Timestamp int64  `json:"timestamp"` | ||||||
| 		Snippets  string `json:"snippets"` | 		Snippets  string `json:"snippets"` | ||||||
|  | 		Memory    string `json:"memory"` | ||||||
| 	}{ | 	}{ | ||||||
| 		"TestRunFinished", | 		"TestRunFinished", | ||||||
| 		status.String(), | 		status.String(), | ||||||
| 		time.Now().UnixNano() / nanoSec, | 		time.Now().UnixNano() / nanoSec, | ||||||
| 		snips, | 		snips, | ||||||
|  | 		"", // @TODO not sure that could be correctly implemented | ||||||
| 	}) | 	}) | ||||||
| } | } | ||||||
| 
 | 
 | ||||||
|  |  | ||||||
		Загрузка…
	
	Создание таблицы
		
		Сослаться в новой задаче
	
	 gedi
						gedi