Added a fixtures folder for expected test output
Этот коммит содержится в:
		
							родитель
							
								
									ee9f3f0a52
								
							
						
					
					
						коммит
						680d2683cc
					
				
					 5 изменённых файлов: 48 добавлений и 81 удалений
				
			
		|  | @ -1,25 +1,4 @@ | ||||||
| package godog | [ | ||||||
| 
 |  | ||||||
| import ( |  | ||||||
| 	"fmt" |  | ||||||
| 	"testing" |  | ||||||
| ) |  | ||||||
| 
 |  | ||||||
| func TestSucceedWithCucumber(t *testing.T) { |  | ||||||
| 	const format = "cucumber" |  | ||||||
| 
 |  | ||||||
| 	// Will test concurrency setting 0 and 1, which means no concurrency. |  | ||||||
| 	for concurrency := range make([]int, 2) { |  | ||||||
| 		t.Run( |  | ||||||
| 			fmt.Sprintf("%s_concurrency_%d", format, concurrency), |  | ||||||
| 			func(t *testing.T) { |  | ||||||
| 				testSucceedRun(t, format, concurrency, expectedOutputCucumber) |  | ||||||
| 			}, |  | ||||||
| 		) |  | ||||||
| 	} |  | ||||||
| } |  | ||||||
| 
 |  | ||||||
| const expectedOutputCucumber = `[ |  | ||||||
|     { |     { | ||||||
|         "uri": "features/background.feature", |         "uri": "features/background.feature", | ||||||
|         "id": "run-background", |         "id": "run-background", | ||||||
|  | @ -4023,7 +4002,7 @@ const expectedOutputCucumber = `[ | ||||||
|                         "name": "the undefined step snippets should be:", |                         "name": "the undefined step snippets should be:", | ||||||
|                         "line": 21, |                         "line": 21, | ||||||
|                         "doc_string": { |                         "doc_string": { | ||||||
|                             "value": "func iSendRequestTo(arg1, arg2 string) error {\n        return godog.ErrPending\n}\n\nfunc theResponseCodeShouldBe(arg1 int) error {\n        return godog.ErrPending\n}\n\nfunc FeatureContext(s *godog.Suite) {\n        s.Step(` + "`" + `^I send \"([^\"]*)\" request to \"([^\"]*)\"$` + "`" + `, iSendRequestTo)\n        s.Step(` + "`" + `^the response code should be (\\d+)$` + "`" + `, theResponseCodeShouldBe)\n}", |                             "value": "func iSendRequestTo(arg1, arg2 string) error {\n        return godog.ErrPending\n}\n\nfunc theResponseCodeShouldBe(arg1 int) error {\n        return godog.ErrPending\n}\n\nfunc FeatureContext(s *godog.Suite) {\n        s.Step(`^I send \"([^\"]*)\" request to \"([^\"]*)\"$`, iSendRequestTo)\n        s.Step(`^the response code should be (\\d+)$`, theResponseCodeShouldBe)\n}", | ||||||
|                             "content_type": "", |                             "content_type": "", | ||||||
|                             "line": 22 |                             "line": 22 | ||||||
|                         }, |                         }, | ||||||
|  | @ -4079,7 +4058,7 @@ const expectedOutputCucumber = `[ | ||||||
|                         "name": "the undefined step snippets should be:", |                         "name": "the undefined step snippets should be:", | ||||||
|                         "line": 49, |                         "line": 49, | ||||||
|                         "doc_string": { |                         "doc_string": { | ||||||
|                             "value": "func iSendRequestToWith(arg1, arg2 string, arg3 *gherkin.DataTable) error {\n        return godog.ErrPending\n}\n\nfunc theResponseCodeShouldBeAndHeaderShouldBe(arg1 int, arg2, arg3 string) error {\n        return godog.ErrPending\n}\n\nfunc FeatureContext(s *godog.Suite) {\n        s.Step(` + "`" + `^I send \"([^\"]*)\" request to \"([^\"]*)\" with:$` + "`" + `, iSendRequestToWith)\n        s.Step(` + "`" + `^the response code should be (\\d+) and header \"([^\"]*)\" should be \"([^\"]*)\"$` + "`" + `, theResponseCodeShouldBeAndHeaderShouldBe)\n}", |                             "value": "func iSendRequestToWith(arg1, arg2 string, arg3 *gherkin.DataTable) error {\n        return godog.ErrPending\n}\n\nfunc theResponseCodeShouldBeAndHeaderShouldBe(arg1 int, arg2, arg3 string) error {\n        return godog.ErrPending\n}\n\nfunc FeatureContext(s *godog.Suite) {\n        s.Step(`^I send \"([^\"]*)\" request to \"([^\"]*)\" with:$`, iSendRequestToWith)\n        s.Step(`^the response code should be (\\d+) and header \"([^\"]*)\" should be \"([^\"]*)\"$`, theResponseCodeShouldBeAndHeaderShouldBe)\n}", | ||||||
|                             "content_type": "", |                             "content_type": "", | ||||||
|                             "line": 50 |                             "line": 50 | ||||||
|                         }, |                         }, | ||||||
|  | @ -4152,7 +4131,7 @@ const expectedOutputCucumber = `[ | ||||||
|                         "name": "the undefined step snippets should be:", |                         "name": "the undefined step snippets should be:", | ||||||
|                         "line": 80, |                         "line": 80, | ||||||
|                         "doc_string": { |                         "doc_string": { | ||||||
|                             "value": "func iPullFromGithubcom() error {\n        return godog.ErrPending\n}\n\nfunc theProjectShouldBeThere() error {\n        return godog.ErrPending\n}\n\nfunc FeatureContext(s *godog.Suite) {\n        s.Step(` + "`" + `^I pull from github\\.com$` + "`" + `, iPullFromGithubcom)\n        s.Step(` + "`" + `^the project should be there$` + "`" + `, theProjectShouldBeThere)\n}", |                             "value": "func iPullFromGithubcom() error {\n        return godog.ErrPending\n}\n\nfunc theProjectShouldBeThere() error {\n        return godog.ErrPending\n}\n\nfunc FeatureContext(s *godog.Suite) {\n        s.Step(`^I pull from github\\.com$`, iPullFromGithubcom)\n        s.Step(`^the project should be there$`, theProjectShouldBeThere)\n}", | ||||||
|                             "content_type": "", |                             "content_type": "", | ||||||
|                             "line": 81 |                             "line": 81 | ||||||
|                         }, |                         }, | ||||||
|  | @ -4208,7 +4187,7 @@ const expectedOutputCucumber = `[ | ||||||
|                         "name": "the undefined step snippets should be:", |                         "name": "the undefined step snippets should be:", | ||||||
|                         "line": 106, |                         "line": 106, | ||||||
|                         "doc_string": { |                         "doc_string": { | ||||||
|                             "value": "func thereIsAWhichCosts(arg1 string, arg2 int) error {\n        return godog.ErrPending\n}\n\nfunc iAddTheToTheBasket(arg1 string) error {\n        return godog.ErrPending\n}\n\nfunc FeatureContext(s *godog.Suite) {\n        s.Step(` + "`" + `^there is a \"([^\"]*)\", which costs £(\\d+)$` + "`" + `, thereIsAWhichCosts)\n        s.Step(` + "`" + `^I add the \"([^\"]*)\" to the basket$` + "`" + `, iAddTheToTheBasket)\n}", |                             "value": "func thereIsAWhichCosts(arg1 string, arg2 int) error {\n        return godog.ErrPending\n}\n\nfunc iAddTheToTheBasket(arg1 string) error {\n        return godog.ErrPending\n}\n\nfunc FeatureContext(s *godog.Suite) {\n        s.Step(`^there is a \"([^\"]*)\", which costs £(\\d+)$`, thereIsAWhichCosts)\n        s.Step(`^I add the \"([^\"]*)\" to the basket$`, iAddTheToTheBasket)\n}", | ||||||
|                             "content_type": "", |                             "content_type": "", | ||||||
|                             "line": 107 |                             "line": 107 | ||||||
|                         }, |                         }, | ||||||
|  | @ -4264,7 +4243,7 @@ const expectedOutputCucumber = `[ | ||||||
|                         "name": "the undefined step snippets should be:", |                         "name": "the undefined step snippets should be:", | ||||||
|                         "line": 132, |                         "line": 132, | ||||||
|                         "doc_string": { |                         "doc_string": { | ||||||
|                             "value": "func whichCosts(arg1 string, arg2 int) error {\n        return godog.ErrPending\n}\n\nfunc godogs(arg1 int) error {\n        return godog.ErrPending\n}\n\nfunc FeatureContext(s *godog.Suite) {\n        s.Step(` + "`" + `^\"([^\"]*)\", which costs £(\\d+)$` + "`" + `, whichCosts)\n        s.Step(` + "`" + `^(\\d+) godogs$` + "`" + `, godogs)\n}", |                             "value": "func whichCosts(arg1 string, arg2 int) error {\n        return godog.ErrPending\n}\n\nfunc godogs(arg1 int) error {\n        return godog.ErrPending\n}\n\nfunc FeatureContext(s *godog.Suite) {\n        s.Step(`^\"([^\"]*)\", which costs £(\\d+)$`, whichCosts)\n        s.Step(`^(\\d+) godogs$`, godogs)\n}", | ||||||
|                             "content_type": "", |                             "content_type": "", | ||||||
|                             "line": 133 |                             "line": 133 | ||||||
|                         }, |                         }, | ||||||
|  | @ -4610,4 +4589,4 @@ const expectedOutputCucumber = `[ | ||||||
|             } |             } | ||||||
|         ] |         ] | ||||||
|     } |     } | ||||||
| ]` | ] | ||||||
|  | @ -1,25 +1,4 @@ | ||||||
| package godog | <?xml version="1.0" encoding="UTF-8"?> | ||||||
| 
 |  | ||||||
| import ( |  | ||||||
| 	"fmt" |  | ||||||
| 	"testing" |  | ||||||
| ) |  | ||||||
| 
 |  | ||||||
| func TestSucceedWithJUnit(t *testing.T) { |  | ||||||
| 	const format = "junit" |  | ||||||
| 
 |  | ||||||
| 	// Will test concurrency setting 0, 1, 2 and 3. |  | ||||||
| 	for concurrency := range make([]int, 4) { |  | ||||||
| 		t.Run( |  | ||||||
| 			fmt.Sprintf("%s_concurrency_%d", format, concurrency), |  | ||||||
| 			func(t *testing.T) { |  | ||||||
| 				testSucceedRun(t, format, concurrency, expectedOutputJUnit) |  | ||||||
| 			}, |  | ||||||
| 		) |  | ||||||
| 	} |  | ||||||
| } |  | ||||||
| 
 |  | ||||||
| const expectedOutputJUnit = `<?xml version="1.0" encoding="UTF-8"?> |  | ||||||
| <testsuites name="succeed" tests="60" skipped="0" failures="0" errors="0" time="0s"> | <testsuites name="succeed" tests="60" skipped="0" failures="0" errors="0" time="0s"> | ||||||
|   <testsuite name="cucumber json formatter" tests="9" skipped="0" failures="0" errors="0" time="0s"> |   <testsuite name="cucumber json formatter" tests="9" skipped="0" failures="0" errors="0" time="0s"> | ||||||
|     <testcase name="Support of Feature Plus Scenario Node" status="passed" time="0s"></testcase> |     <testcase name="Support of Feature Plus Scenario Node" status="passed" time="0s"></testcase> | ||||||
|  | @ -103,4 +82,4 @@ const expectedOutputJUnit = `<?xml version="1.0" encoding="UTF-8"?> | ||||||
|   <testsuite name="užkrauti savybes" tests="1" skipped="0" failures="0" errors="0" time="0s"> |   <testsuite name="užkrauti savybes" tests="1" skipped="0" failures="0" errors="0" time="0s"> | ||||||
|     <testcase name="savybių užkrovimas iš aplanko" status="passed" time="0s"></testcase> |     <testcase name="savybių užkrovimas iš aplanko" status="passed" time="0s"></testcase> | ||||||
|   </testsuite> |   </testsuite> | ||||||
| </testsuites>` | </testsuites> | ||||||
							
								
								
									
										9
									
								
								fixtures/progress_output.txt
									
										
									
									
									
										Обычный файл
									
								
							
							
						
						
									
										9
									
								
								fixtures/progress_output.txt
									
										
									
									
									
										Обычный файл
									
								
							|  | @ -0,0 +1,9 @@ | ||||||
|  | ...................................................................... 70 | ||||||
|  | ...................................................................... 140 | ||||||
|  | ...................................................................... 210 | ||||||
|  | .......................................                                249 | ||||||
|  | 
 | ||||||
|  | 
 | ||||||
|  | 60 scenarios (60 passed) | ||||||
|  | 249 steps (249 passed) | ||||||
|  | 0s | ||||||
|  | @ -1,30 +0,0 @@ | ||||||
| package godog |  | ||||||
| 
 |  | ||||||
| import ( |  | ||||||
| 	"fmt" |  | ||||||
| 	"testing" |  | ||||||
| ) |  | ||||||
| 
 |  | ||||||
| func TestSucceedRun(t *testing.T) { |  | ||||||
| 	const format = "progress" |  | ||||||
| 
 |  | ||||||
| 	// Will test concurrency setting 0, 1, 2 and 3. |  | ||||||
| 	for concurrency := range make([]int, 4) { |  | ||||||
| 		t.Run( |  | ||||||
| 			fmt.Sprintf("%s_concurrency_%d", format, concurrency), |  | ||||||
| 			func(t *testing.T) { |  | ||||||
| 				testSucceedRun(t, format, concurrency, expectedOutputProgress) |  | ||||||
| 			}, |  | ||||||
| 		) |  | ||||||
| 	} |  | ||||||
| } |  | ||||||
| 
 |  | ||||||
| const expectedOutputProgress = `...................................................................... 70 |  | ||||||
| ...................................................................... 140 |  | ||||||
| ...................................................................... 210 |  | ||||||
| .......................................                                249 |  | ||||||
| 
 |  | ||||||
| 
 |  | ||||||
| 60 scenarios (60 passed) |  | ||||||
| 249 steps (249 passed) |  | ||||||
| 0s` |  | ||||||
							
								
								
									
										30
									
								
								run_test.go
									
										
									
									
									
								
							
							
						
						
									
										30
									
								
								run_test.go
									
										
									
									
									
								
							|  | @ -276,6 +276,36 @@ func TestFeatureFilePathParser(t *testing.T) { | ||||||
| 	} | 	} | ||||||
| } | } | ||||||
| 
 | 
 | ||||||
|  | type succeedRunTestCase struct { | ||||||
|  | 	format      string // formatter to use | ||||||
|  | 	concurrency int    // concurrency option range to test | ||||||
|  | 	filename    string // expected output file | ||||||
|  | } | ||||||
|  | 
 | ||||||
|  | func TestSucceedRun(t *testing.T) { | ||||||
|  | 	testCases := []succeedRunTestCase{ | ||||||
|  | 		{format: "progress", concurrency: 4, filename: "fixtures/progress_output.txt"}, | ||||||
|  | 		{format: "junit", concurrency: 4, filename: "fixtures/junit_output.xml"}, | ||||||
|  | 		{format: "cucumber", concurrency: 2, filename: "fixtures/cucumber_output.json"}, | ||||||
|  | 	} | ||||||
|  | 
 | ||||||
|  | 	for _, tc := range testCases { | ||||||
|  | 		expectedOutput, err := ioutil.ReadFile(tc.filename) | ||||||
|  | 		if err != nil { | ||||||
|  | 			t.Fatal(err) | ||||||
|  | 		} | ||||||
|  | 
 | ||||||
|  | 		for concurrency := range make([]int, tc.concurrency) { | ||||||
|  | 			t.Run( | ||||||
|  | 				fmt.Sprintf("%s/concurrency/%d", tc.format, concurrency), | ||||||
|  | 				func(t *testing.T) { | ||||||
|  | 					testSucceedRun(t, tc.format, concurrency, string(expectedOutput)) | ||||||
|  | 				}, | ||||||
|  | 			) | ||||||
|  | 		} | ||||||
|  | 	} | ||||||
|  | } | ||||||
|  | 
 | ||||||
| func testSucceedRun(t *testing.T, format string, concurrency int, expectedOutput string) { | func testSucceedRun(t *testing.T, format string, concurrency int, expectedOutput string) { | ||||||
| 	output := new(bytes.Buffer) | 	output := new(bytes.Buffer) | ||||||
| 
 | 
 | ||||||
|  |  | ||||||
		Загрузка…
	
	Создание таблицы
		
		Сослаться в новой задаче
	
	 Fredrik Lönnblad
						Fredrik Lönnblad