How to use specHeading method of execution Package

Best Gauge code snippet using execution.specHeading

transform_test.go

Source:transform_test.go Github

copy

Full Screen

1/*----------------------------------------------------------------2 * Copyright (c) ThoughtWorks, Inc.3 * Licensed under the Apache License, Version 2.04 * See LICENSE in the project root for license information.5 *----------------------------------------------------------------*/6package generator7import (8 "os"9 "path/filepath"10 "reflect"11 "testing"12 gm "github.com/getgauge/html-report/gauge_messages"13 "github.com/kylelemons/godebug/pretty"14)15func checkEqual(t *testing.T, test string, want, got interface{}) {16 if diff := pretty.Compare(got, want); diff != "" {17 t.Errorf("Test:%s\n diff: (-got +want)\n%s", test, diff)18 }19}20func newCommentItem(str string) *gm.ProtoItem {21 return &gm.ProtoItem{22 ItemType: gm.ProtoItem_Comment,23 Comment: &gm.ProtoComment{24 Text: str,25 },26 }27}28func newScenarioItem(scn *gm.ProtoScenario) *gm.ProtoItem {29 return &gm.ProtoItem{30 ItemType: gm.ProtoItem_Scenario,31 Scenario: scn,32 }33}34func newTableItem(headers []string, rows [][]string) *gm.ProtoItem {35 r := make([]*gm.ProtoTableRow, len(rows))36 for i, row := range rows {37 r[i] = &gm.ProtoTableRow{Cells: row}38 }39 return &gm.ProtoItem{40 ItemType: gm.ProtoItem_Table,41 Table: &gm.ProtoTable{Headers: &gm.ProtoTableRow{Cells: headers}, Rows: r},42 }43}44func newStepItem(failed, skipped bool, frags []*gm.Fragment) *gm.ProtoItem {45 return &gm.ProtoItem{46 ItemType: gm.ProtoItem_Step,47 Step: &gm.ProtoStep{48 StepExecutionResult: &gm.ProtoStepExecutionResult{49 ExecutionResult: &gm.ProtoExecutionResult{50 Failed: failed,51 ExecutionTime: 211316,52 },53 Skipped: skipped,54 },55 Fragments: frags,56 },57 }58}59func newDynamicParam(val string) *gm.Parameter {60 return &gm.Parameter{61 ParameterType: gm.Parameter_Dynamic,62 Value: val,63 }64}65func newStaticParam(val string) *gm.Parameter {66 return &gm.Parameter{67 ParameterType: gm.Parameter_Static,68 Value: val,69 }70}71func newTableParam(headers []string, rows [][]string) *gm.Parameter {72 return &gm.Parameter{73 ParameterType: gm.Parameter_Table,74 Table: newTableItem(headers, rows).GetTable(),75 }76}77func newTextFragment(val string) *gm.Fragment {78 return &gm.Fragment{79 FragmentType: gm.Fragment_Text,80 Text: val,81 }82}83func newParamFragment(p *gm.Parameter) *gm.Fragment {84 return &gm.Fragment{85 FragmentType: gm.Fragment_Parameter,86 Parameter: p,87 }88}89func newConceptItem(heading string, steps []*gm.ProtoItem, cptRes *gm.ProtoStepExecutionResult) *gm.ProtoItem {90 return &gm.ProtoItem{91 ItemType: gm.ProtoItem_Concept,92 Concept: &gm.ProtoConcept{93 ConceptStep: newStepItem(false, false, []*gm.Fragment{newTextFragment(heading)}).GetStep(),94 Steps: steps,95 ConceptExecutionResult: cptRes,96 },97 }98}99func newScreenshot() string {100 return `failure-screenshot-file.png`101}102func newStackTrace() string {103 return `StepImplementation.foo(StepImplementation.java:16)104sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)105sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:62)106sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43)107java.lang.reflect.Method.invoke(Method.java:483)108com.thoughtworks.gauge.execution.MethodExecutor.execute(MethodExecutor.java:32)109com.thoughtworks.gauge.execution.HooksExecutor$TaggedHookExecutor.executeHook(HooksExecutor.java:98)110com.thoughtworks.gauge.execution.HooksExecutor$TaggedHookExecutor.execute(HooksExecutor.java:84)111com.thoughtworks.gauge.execution.HooksExecutor.execute(HooksExecutor.java:41)112com.thoughtworks.gauge.processor.MethodExecutionMessageProcessor.executeHooks(MethodExecutionMessageProcessor.java:55)113com.thoughtworks.gauge.processor.SuiteExecutionStartingProcessor.process(SuiteExecutionStartingProcessor.java:26)114com.thoughtworks.gauge.connection.MessageDispatcher.dispatchMessages(MessageDispatcher.java:72)115com.thoughtworks.gauge.GaugeRuntime.main(GaugeRuntime.java:37)`116}117var specRes1 = &gm.ProtoSpecResult{118 Failed: false,119 Skipped: false,120 ExecutionTime: 211316,121 ProtoSpec: &gm.ProtoSpec{122 SpecHeading: "specRes1",123 Tags: []string{"tag1", "tag2"},124 FileName: filepath.Join(string(os.PathSeparator), "tmp", "gauge", "specs", "foobar.spec"),125 IsTableDriven: true,126 Items: []*gm.ProtoItem{127 newCommentItem("\n"),128 newCommentItem("This is an executable specification file. This file follows markdown syntax."),129 newCommentItem("\n"),130 newCommentItem("To execute this specification, run"),131 newCommentItem("\tgauge specs"),132 newCommentItem("\n"),133 newTableItem([]string{"Word", "Count"}, [][]string{134 {"Gauge", "3"},135 {"Mingle", "2"},136 }),137 newCommentItem("Comment 1"),138 newCommentItem("Comment 2"),139 newCommentItem("Comment 3"),140 },141 PreHookMessages: []string{"Before Spec Hook Message"},142 PostHookMessages: []string{"After Spec Hook Message"},143 },144}145var spec1 = &spec{146 SpecHeading: "specRes1",147 Tags: []string{"tag1", "tag2"},148 FileName: "/tmp/gauge/specs/foobar.spec",149 SpecFileName: "/tmp/gauge/specs/foobar.spec",150 ExecutionTime: 211316,151 IsTableDriven: true,152 Datatable: &table{153 Headers: []string{"Word", "Count"},154 Rows: []*row{155 {Cells: []string{"Gauge", "3"}},156 {Cells: []string{"Mingle", "2"}}}},157 CommentsBeforeDatatable: `158This is an executable specification file. This file follows markdown syntax.159To execute this specification, run160 gauge specs161`,162 CommentsAfterDatatable: `Comment 1163Comment 2164Comment 3`,165}166var spec2 = &spec{167 ExecutionStatus: fail,168 ExecutionTime: 211316,169 FileName: "specRes2.spec",170 SpecHeading: "specRes2",171 Tags: []string{"tag1", "tag2", "tag3"},172}173var spec3 = &spec{174 ExecutionStatus: skip,175 ExecutionTime: 211316,176 FileName: "specRes3.spec",177 SpecHeading: "specRes3",178 Tags: []string{"tag1"},179}180var datatableDrivenSpec = &gm.ProtoSpecResult{181 Failed: false,182 Skipped: false,183 ExecutionTime: 211316,184 ProtoSpec: &gm.ProtoSpec{185 SpecHeading: "specRes1",186 FileName: "/tmp/gauge/specs/foobar.spec",187 IsTableDriven: true,188 Items: []*gm.ProtoItem{189 newTableItem(190 []string{"Word", "Count"}, [][]string{191 {"Gauge", "3"},192 {"Mingle", "2"},193 }),194 {195 ItemType: gm.ProtoItem_TableDrivenScenario,196 TableDrivenScenario: &gm.ProtoTableDrivenScenario{197 Scenario: &gm.ProtoScenario{198 ScenarioHeading: "Scenario 1",199 ExecutionStatus: gm.ExecutionStatus_FAILED,200 ScenarioItems: []*gm.ProtoItem{newStepItem(true, false, []*gm.Fragment{newTextFragment("Step1")})},201 },202 TableRowIndex: int32(0),203 },204 },205 {206 ItemType: gm.ProtoItem_TableDrivenScenario,207 TableDrivenScenario: &gm.ProtoTableDrivenScenario{208 Scenario: &gm.ProtoScenario{209 ScenarioHeading: "Scenario 1",210 ExecutionStatus: gm.ExecutionStatus_PASSED,211 ScenarioItems: []*gm.ProtoItem{newStepItem(false, false, []*gm.Fragment{newTextFragment("Step1")})},212 },213 TableRowIndex: int32(1),214 },215 },216 },217 },218}219var specResWithSpecHookFailure = &gm.ProtoSpecResult{220 Failed: false,221 Skipped: true,222 ExecutionTime: 211316,223 ProtoSpec: &gm.ProtoSpec{224 FileName: "specfile-1.spec",225 SpecHeading: "specRes3",226 Tags: []string{"tag1"},227 PreHookFailures: []*gm.ProtoHookFailure{{228 ErrorMessage: "err",229 StackTrace: "Stacktrace",230 FailureScreenshotFile: "Screenshot.png",231 }},232 PostHookFailures: []*gm.ProtoHookFailure{{233 ErrorMessage: "err",234 StackTrace: "Stacktrace",235 FailureScreenshotFile: "Screenshot.png",236 }},237 },238}239var suiteRes1 = &SuiteResult{240 ProjectName: "projName",241 Environment: "ci-java",242 Tags: "!unimplemented",243 SuccessRate: 80,244 ExecutionTime: 113163,245 Timestamp: "Jun 3, 2016 at 12:29pm",246 SpecResults: []*spec{247 {Scenarios: make([]*scenario, 2)},248 {Scenarios: make([]*scenario, 1)},249 {Scenarios: make([]*scenario, 2)},250 {Scenarios: make([]*scenario, 1)},251 {Scenarios: make([]*scenario, 2)},252 {Scenarios: make([]*scenario, 1)},253 {Scenarios: make([]*scenario, 2)},254 {Scenarios: make([]*scenario, 1)},255 {Scenarios: make([]*scenario, 2)},256 {Scenarios: make([]*scenario, 1)},257 {Scenarios: make([]*scenario, 2)},258 {Scenarios: make([]*scenario, 1)},259 {Scenarios: make([]*scenario, 2)},260 {Scenarios: make([]*scenario, 1)},261 {Scenarios: make([]*scenario, 2)},262 },263 PassedScenarioCount: 7,264 SkippedScenarioCount: 10,265 FailedScenarioCount: 6,266 FailedSpecsCount: 2,267 SkippedSpecsCount: 5,268 PassedSpecsCount: 8,269 PreHookMessages: []string{"Before Suite Message"},270 PostHookMessages: []string{"After Suite Message"},271}272var scn = &gm.ProtoScenario{273 ScenarioHeading: "Vowel counts in single word",274 ExecutionStatus: gm.ExecutionStatus_PASSED,275 Tags: []string{"foo", "bar"},276 ExecutionTime: 113163,277 Contexts: []*gm.ProtoItem{278 newStepItem(false, false, []*gm.Fragment{newTextFragment("Context Step1")}),279 newStepItem(true, false, []*gm.Fragment{newTextFragment("Context Step2")}),280 },281 ScenarioItems: []*gm.ProtoItem{282 newCommentItem("Comment0"),283 newStepItem(true, false, []*gm.Fragment{newTextFragment("Step1")}),284 newCommentItem("Comment1"),285 newCommentItem("Comment2"),286 newStepItem(false, false, []*gm.Fragment{newTextFragment("Step2")}),287 newCommentItem("Comment3"),288 },289 TearDownSteps: []*gm.ProtoItem{290 newStepItem(false, false, []*gm.Fragment{newTextFragment("Teardown Step1")}),291 newStepItem(true, false, []*gm.Fragment{newTextFragment("Teardown Step2")}),292 },293 PreHookMessages: []string{"Before Scenario Message"},294 PostHookMessages: []string{"After Scenario Message"},295 RetriesCount: 4,296}297var scnWithHookFailure = &gm.ProtoScenario{298 ScenarioHeading: "Vowel counts in single word",299 ExecutionStatus: gm.ExecutionStatus_FAILED,300 ExecutionTime: 113163,301 ScenarioItems: []*gm.ProtoItem{302 newStepItem(true, false, []*gm.Fragment{newTextFragment("Step1")}),303 },304 PreHookFailure: &gm.ProtoHookFailure{305 ErrorMessage: "err",306 StackTrace: "Stacktrace",307 FailureScreenshotFile: "Screenshot.png",308 },309 PostHookFailure: &gm.ProtoHookFailure{310 ErrorMessage: "err",311 StackTrace: "Stacktrace",312 FailureScreenshotFile: "Screenshot.png",313 },314}315var skippedProtoSce = &gm.ProtoScenario{316 ScenarioHeading: "Vowel counts in single word",317 ExecutionStatus: gm.ExecutionStatus_SKIPPED,318 ExecutionTime: 0,319 ScenarioItems: []*gm.ProtoItem{320 newStepItem(true, false, []*gm.Fragment{newTextFragment("Step1")}),321 },322}323var suiteRes2 = &SuiteResult{324 SpecResults: []*spec{spec1, spec2, spec3},325}326var protoStep = &gm.ProtoStep{327 Fragments: []*gm.Fragment{328 newTextFragment("Say "),329 newParamFragment(newStaticParam("hi")),330 newTextFragment(" to "),331 newParamFragment(newDynamicParam("gauge")),332 newParamFragment(newTableParam([]string{"Word", "Count"}, [][]string{333 {"Gauge", "3"},334 {"Mingle", "2"},335 })),336 },337 StepExecutionResult: &gm.ProtoStepExecutionResult{338 ExecutionResult: &gm.ProtoExecutionResult{339 ExecutionTime: 211316,340 },341 SkippedReason: "Step impl not found",342 Skipped: true,343 },344}345var protoStepWithScreenshots = &gm.ProtoStep{346 Fragments: []*gm.Fragment{347 newTextFragment("Say "),348 newParamFragment(newStaticParam("hi")),349 newTextFragment(" to "),350 newParamFragment(newDynamicParam("gauge")),351 newParamFragment(newTableParam([]string{"Word", "Count"}, [][]string{352 {"Gauge", "3"},353 {"Mingle", "2"},354 })),355 },356 StepExecutionResult: &gm.ProtoStepExecutionResult{357 ExecutionResult: &gm.ProtoExecutionResult{358 ExecutionTime: 211316,359 ScreenshotFiles: []string{"screenshot1.png", "screenshot2.png"},360 },361 SkippedReason: "Step impl not found",362 Skipped: true,363 },364}365var protoConcept = &gm.ProtoConcept{366 ConceptStep: newStepItem(false, false, []*gm.Fragment{367 newTextFragment("Say "),368 newParamFragment(newDynamicParam("hello")),369 newTextFragment(" to "),370 newParamFragment(newTableParam([]string{"Word", "Count"}, [][]string{371 {"Gauge", "3"},372 {"Mingle", "2"},373 })),374 }).GetStep(),375 Steps: []*gm.ProtoItem{376 {377 ItemType: gm.ProtoItem_Concept,378 Concept: &gm.ProtoConcept{379 ConceptStep: newStepItem(false, false, []*gm.Fragment{380 newTextFragment("Tell "),381 newParamFragment(newDynamicParam("hello")),382 }).GetStep(),383 Steps: []*gm.ProtoItem{newStepItem(false, false, []*gm.Fragment{newTextFragment("Say Hi")})},384 ConceptExecutionResult: &gm.ProtoStepExecutionResult{385 ExecutionResult: &gm.ProtoExecutionResult{Failed: false, ExecutionTime: 211316},386 },387 },388 },389 newStepItem(false, false, []*gm.Fragment{390 newTextFragment("Say "),391 newParamFragment(newStaticParam("hi")),392 newTextFragment(" to "),393 newParamFragment(newDynamicParam("gauge")),394 newParamFragment(newTableParam([]string{"Word", "Count"}, [][]string{395 {"Gauge", "3"},396 {"Mingle", "2"},397 })),398 }),399 },400 ConceptExecutionResult: &gm.ProtoStepExecutionResult{401 ExecutionResult: &gm.ProtoExecutionResult{Failed: false, ExecutionTime: 211316},402 },403}404var protoStepWithSpecialParams = &gm.ProtoStep{405 Fragments: []*gm.Fragment{406 newTextFragment("Say "),407 {408 FragmentType: gm.Fragment_Parameter,409 Parameter: &gm.Parameter{410 Name: "file:foo.txt",411 ParameterType: gm.Parameter_Special_String,412 Value: "hi",413 },414 },415 newTextFragment(" to "),416 {417 FragmentType: gm.Fragment_Parameter,418 Parameter: &gm.Parameter{419 ParameterType: gm.Parameter_Special_Table,420 Name: "table:myTable.csv",421 Table: newTableItem([]string{"Word", "Count"}, [][]string{422 {"Gauge", "3"},423 {"Mingle", "2"},424 }).GetTable(),425 },426 },427 },428 StepExecutionResult: &gm.ProtoStepExecutionResult{429 ExecutionResult: &gm.ProtoExecutionResult{430 Failed: false,431 ExecutionTime: 211316,432 },433 },434}435var protoStepWithAfterHookFailure = &gm.ProtoStep{436 Fragments: []*gm.Fragment{newTextFragment("Some Step")},437 StepExecutionResult: &gm.ProtoStepExecutionResult{438 ExecutionResult: &gm.ProtoExecutionResult{439 Failed: true,440 ExecutionTime: 211316,441 },442 PostHookFailure: &gm.ProtoHookFailure{443 ErrorMessage: "err",444 StackTrace: "Stacktrace",445 FailureScreenshotFile: "Screenshot.png",446 },447 },448}449var failedHookFailure = &gm.ProtoHookFailure{450 ErrorMessage: "java.lang.RuntimeException",451 StackTrace: newStackTrace(),452 FailureScreenshotFile: newScreenshot(),453}454func TestToOverview(t *testing.T) {455 want := &overview{456 ProjectName: "projName",457 Env: "ci-java",458 Tags: "!unimplemented",459 SuccessRate: 80.00,460 ExecutionTime: "00:01:53",461 Timestamp: "Jun 3, 2016 at 12:29pm",462 Summary: &summary{Total: 15, Failed: 2, Passed: 8, Skipped: 5},463 ScenarioSummary: &summary{Total: 23, Failed: 6, Passed: 7, Skipped: 10},464 PreHookMessages: []string{"Before Suite Message"},465 PostHookMessages: []string{"After Suite Message"},466 }467 got := toOverview(suiteRes1, "")468 checkEqual(t, "", want, got)469}470func TestToSidebar(t *testing.T) {471 want := &sidebar{472 IsBeforeHookFailure: false,473 Specs: []*specsMeta{474 newSpecsMeta("specRes2", "00:03:31", true, false, []string{"tag1", "tag2", "tag3"}, "specRes2.html"),475 newSpecsMeta("specRes3", "00:03:31", false, true, []string{"tag1"}, "specRes3.html"),476 newSpecsMeta("specRes1", "00:03:31", false, false, []string{"tag1", "tag2"}, "foobar.html"),477 },478 }479 got := toSidebar(suiteRes2, "")480 if !reflect.DeepEqual(got, want) {481 t.Errorf("want:\n%v\ngot:\n%v\n", want, got)482 }483}484func TestToSpecHeader(t *testing.T) {485 want := &specHeader{486 SpecName: "specRes1",487 ExecutionTime: "00:03:31",488 FileName: "/tmp/gauge/specs/foobar.spec",489 Tags: []string{"tag1", "tag2"},490 Summary: &summary{},491 }492 got := toSpecHeader(spec1)493 checkEqual(t, "", want, got)494}495func TestToSpec(t *testing.T) {496 want := &spec{497 CommentsBeforeDatatable: "\n\n\nThis is an executable specification file. This file follows markdown syntax.\n\n\nTo execute this specification, run\n\tgauge specs\n\n",498 Datatable: &table{499 Headers: []string{"Word", "Count"},500 Rows: []*row{{Cells: []string{"Gauge", "3"}, Result: skip}, {Cells: []string{"Mingle", "2"}, Result: skip}},501 },502 CommentsAfterDatatable: "\nComment 1\nComment 2\nComment 3",503 Scenarios: make([]*scenario, 0),504 Errors: make([]buildError, 0),505 SpecHeading: "specRes1",506 Tags: []string{"tag1", "tag2"},507 FileName: filepath.Join(string(os.PathSeparator), "tmp", "gauge", "specs", "foobar.spec"),508 SpecFileName: filepath.Join(string(os.PathSeparator), "tmp", "gauge", "specs", "foobar.spec"),509 IsTableDriven: true,510 ExecutionStatus: pass,511 ExecutionTime: 211316,512 PreHookMessages: []string{"Before Spec Hook Message"},513 PostHookMessages: []string{"After Spec Hook Message"},514 }515 got := toSpec(specRes1, "/tmp/gauge/")516 checkEqual(t, "", want, got)517}518func TestToSpecWithScenariosInOrder(t *testing.T) {519 specRes := &gm.ProtoSpecResult{520 Failed: true,521 Skipped: false,522 ExecutionTime: 211316,523 ProtoSpec: &gm.ProtoSpec{524 SpecHeading: "specRes1",525 FileName: "/tmp/gauge/specs/foobar.spec",526 Items: []*gm.ProtoItem{527 newScenarioItem(scn),528 newScenarioItem(scnWithHookFailure),529 newScenarioItem(scnWithHookFailure),530 newScenarioItem(skippedProtoSce),531 newScenarioItem(scn),532 },533 },534 }535 got := toSpec(specRes, "")536 if len(got.Scenarios) != 5 {537 t.Errorf("want:%q\ngot:%q\n", 5, len(got.Scenarios))538 }539 if got.Scenarios[0].ExecutionStatus != fail {540 t.Errorf("want:%q\ngot:%q\n", fail, got.Scenarios[0].ExecutionStatus)541 }542 if got.Scenarios[1].ExecutionStatus != fail {543 t.Errorf("want:%q\ngot:%q\n", fail, got.Scenarios[1].ExecutionStatus)544 }545 if got.Scenarios[2].ExecutionStatus != skip {546 t.Errorf("want:%q\ngot:%q\n", skip, got.Scenarios[2].ExecutionStatus)547 }548 if got.Scenarios[3].ExecutionStatus != pass {549 t.Errorf("want:%q\ngot:%q\n", pass, got.Scenarios[3].ExecutionStatus)550 }551 if got.Scenarios[4].ExecutionStatus != pass {552 t.Errorf("want:%q\ngot:%q\n", pass, got.Scenarios[4].ExecutionStatus)553 }554}555func TestToSpecWithErrors(t *testing.T) {556 specRes := &gm.ProtoSpecResult{557 Failed: true,558 ProtoSpec: &gm.ProtoSpec{FileName: "spec-file-1.spec"},559 Errors: []*gm.Error{560 {561 Filename: "fileName",562 LineNumber: 2,563 Message: "message",564 Type: gm.Error_PARSE_ERROR,565 },566 {567 Filename: "fileName1",568 LineNumber: 4,569 Message: "message1",570 Type: gm.Error_VALIDATION_ERROR,571 },572 },573 }574 want := &spec{575 Errors: []buildError{576 {FileName: "fileName", LineNumber: 2, Message: "message", ErrorType: parseErrorType},577 {FileName: "fileName1", LineNumber: 4, Message: "message1", ErrorType: validationErrorType},578 },579 Scenarios: make([]*scenario, 0),580 FileName: "spec-file-1.spec",581 SpecFileName: "spec-file-1.spec",582 ExecutionStatus: fail,583 }584 got := toSpec(specRes, "")585 checkEqual(t, "", want, got)586}587func TestToSpecForTableDrivenSpec(t *testing.T) {588 want := &spec{589 Datatable: &table{590 Headers: []string{"Word", "Count"},591 Rows: []*row{{Cells: []string{"Gauge", "3"}, Result: fail}, {Cells: []string{"Mingle", "2"}, Result: pass}},592 },593 SpecHeading: "specRes1",594 FileName: filepath.Join(string(os.PathSeparator), "tmp", "gauge", "specs", "foobar.spec"),595 SpecFileName: "/tmp/gauge/specs/foobar.spec",596 IsTableDriven: true,597 ExecutionStatus: pass,598 ExecutionTime: 211316,599 Scenarios: []*scenario{600 {601 Heading: "Scenario 1",602 ExecutionTime: "00:00:00",603 Items: []item{604 {605 Kind: stepKind,606 Step: &step{607 Fragments: []*fragment{{FragmentKind: textFragmentKind, Text: "Step1"}},608 Result: &result{Status: fail, ExecutionTime: "00:03:31"},609 },610 },611 },612 Contexts: make([]item, 0),613 Teardowns: make([]item, 0),614 ExecutionStatus: fail,615 TableRowIndex: 0,616 BeforeScenarioHookFailure: nil,617 AfterScenarioHookFailure: nil,618 },619 {620 Heading: "Scenario 1",621 ExecutionTime: "00:00:00",622 Items: []item{623 {624 Kind: stepKind,625 Step: &step{626 Fragments: []*fragment{{FragmentKind: textFragmentKind, Text: "Step1"}},627 Result: &result{Status: pass, ExecutionTime: "00:03:31"},628 },629 },630 },631 Contexts: make([]item, 0),632 Teardowns: make([]item, 0),633 ExecutionStatus: pass,634 TableRowIndex: 1,635 BeforeScenarioHookFailure: nil,636 AfterScenarioHookFailure: nil,637 },638 },639 BeforeSpecHookFailures: nil,640 AfterSpecHookFailures: nil,641 Errors: make([]buildError, 0),642 PassedScenarioCount: 1,643 FailedScenarioCount: 1,644 SkippedScenarioCount: 0,645 }646 got := toSpec(datatableDrivenSpec, "/tmp/gauge/")647 checkEqual(t, "", want, got)648}649func TestToSpecWithHookFailure(t *testing.T) {650 screenShot := "Screenshot.png"651 want := &spec{652 Scenarios: make([]*scenario, 0),653 BeforeSpecHookFailures: []*hookFailure{newHookFailure("", "Before Spec", "err", screenShot, "Stacktrace")},654 AfterSpecHookFailures: []*hookFailure{newHookFailure("", "After Spec", "err", screenShot, "Stacktrace")},655 Errors: make([]buildError, 0),656 Tags: []string{"tag1"},657 SpecHeading: "specRes3",658 SpecFileName: "specfile-1.spec",659 FileName: "specfile-1.spec",660 ExecutionStatus: skip,661 ExecutionTime: 211316,662 }663 got := toSpec(specResWithSpecHookFailure, "")664 checkEqual(t, "", want, got)665}666func TestToSpecWithFileName(t *testing.T) {667 want := specRes1.GetProtoSpec().GetFileName()668 got := toSpec(specRes1, "/tmp/gauge").FileName669 if got != want {670 t.Errorf("Expecting spec.FileName=%s, got %s\n", want, got)671 }672}673func TestToSpecWithSpecHeading(t *testing.T) {674 want := specRes1.GetProtoSpec().GetSpecHeading()675 got := toSpec(specRes1, "").SpecHeading676 if got != want {677 t.Errorf("Expecting spec.SpecHeading=%s, got %s\n", want, got)678 }679}680func TestToSpecWithTags(t *testing.T) {681 want := specRes1.GetProtoSpec().GetTags()682 got := toSpec(specRes1, "").Tags683 checkEqual(t, "", want, got)684}685func TestToSpecWithDataTableMapsCommentsBeforeDatatable(t *testing.T) {686 want := `687This is an executable specification file. This file follows markdown syntax.688To execute this specification, run689 gauge specs690`691 got := toSpec(specRes1, "").CommentsBeforeDatatable692 checkEqual(t, "", want, got)693}694func TestToSpecWithDataTableMapsCommentsAfterDatatable(t *testing.T) {695 want := `696Comment 1697Comment 2698Comment 3`699 got := toSpec(specRes1, "").CommentsAfterDatatable700 checkEqual(t, "", want, got)701}702func TestToSpecWithDataTableIsTableDriven(t *testing.T) {703 got := toSpec(specRes1, "").IsTableDriven704 if !got {705 t.Errorf("Expecting spec.IsTableDriven=true\n")706 }707}708func TestToSpecWithDataTableHasDatatable(t *testing.T) {709 want := &table{710 Headers: []string{"Word", "Count"},711 Rows: []*row{712 {Cells: []string{"Gauge", "3"}, Result: skip},713 {Cells: []string{"Mingle", "2"}, Result: skip},714 },715 }716 got := toSpec(specRes1, "").Datatable717 checkEqual(t, "", want, got)718}719func TestToSpecWithDataTableExecutionTime(t *testing.T) {720 want := 211316721 got := toSpec(specRes1, "").ExecutionTime722 checkEqual(t, "", want, got)723}724func TestToSpecWithDataTableExecutionStatusPass(t *testing.T) {725 want := pass726 got := toSpec(specRes1, "").ExecutionStatus727 checkEqual(t, "", want, got)728}729func TestToSpecWithDataTableExecutionStatusSkip(t *testing.T) {730 want := skip731 got := toSpec(&gm.ProtoSpecResult{Skipped: true, Failed: false, ProtoSpec: &gm.ProtoSpec{FileName: "spec-file.spec"}}, "").ExecutionStatus732 checkEqual(t, "", want, got)733}734func TestToSpecWithDataTableExecutionStatusFail(t *testing.T) {735 want := fail736 got := toSpec(&gm.ProtoSpecResult{Skipped: false, Failed: true, ProtoSpec: &gm.ProtoSpec{FileName: "spec-file.spec"}}, "").ExecutionStatus737 checkEqual(t, "", want, got)738}739func TestToSpecWithBeforeHookFailure(t *testing.T) {740 want := []*hookFailure{{ErrMsg: "err", HookName: "Before Spec", FailureScreenshotFile: "Screenshot.png", StackTrace: "Stacktrace"}}741 got := toSpec(specResWithSpecHookFailure, "").BeforeSpecHookFailures742 checkEqual(t, "", want, got)743}744func TestToSpecWithAfterHookFailure(t *testing.T) {745 want := []*hookFailure{{ErrMsg: "err", HookName: "After Spec", FailureScreenshotFile: "Screenshot.png", StackTrace: "Stacktrace", TableRowIndex: 0}}746 got := toSpec(specResWithSpecHookFailure, "").AfterSpecHookFailures747 checkEqual(t, "", want, got)748}749func TestToSpecWithScenarios(t *testing.T) {750 got := toSpec(&gm.ProtoSpecResult{751 ProtoSpec: &gm.ProtoSpec{752 Items: []*gm.ProtoItem{753 {754 ItemType: gm.ProtoItem_TableDrivenScenario,755 TableDrivenScenario: &gm.ProtoTableDrivenScenario{756 Scenario: &gm.ProtoScenario{757 ScenarioHeading: "Scenario 1",758 ExecutionStatus: gm.ExecutionStatus_FAILED,759 ScenarioItems: []*gm.ProtoItem{newStepItem(true, false, []*gm.Fragment{newTextFragment("Step1")})},760 },761 TableRowIndex: int32(0),762 },763 },764 {765 ItemType: gm.ProtoItem_TableDrivenScenario,766 TableDrivenScenario: &gm.ProtoTableDrivenScenario{767 Scenario: &gm.ProtoScenario{768 ScenarioHeading: "Scenario 1",769 ExecutionStatus: gm.ExecutionStatus_PASSED,770 ScenarioItems: []*gm.ProtoItem{newStepItem(false, false, []*gm.Fragment{newTextFragment("Step1")})},771 },772 TableRowIndex: int32(1),773 },774 },775 },776 },777 }, "").Scenarios778 if len(got) != 2 {779 t.Errorf("Expected 2 scenarios, got %d\n", len(got))780 }781}782func TestToSpecWithScenariosTableDriven(t *testing.T) {783 got := toSpec(datatableDrivenSpec, "").Scenarios784 if len(got) != 2 {785 t.Errorf("Expected 2 scenarios, got %d\n", len(got))786 }787}788func TestToSpecWithScenarioStatusCounts(t *testing.T) {789 got := toSpec(&gm.ProtoSpecResult{790 ProtoSpec: &gm.ProtoSpec{791 Items: []*gm.ProtoItem{792 {793 ItemType: gm.ProtoItem_TableDrivenScenario,794 TableDrivenScenario: &gm.ProtoTableDrivenScenario{795 Scenario: &gm.ProtoScenario{796 ScenarioHeading: "Scenario 1",797 ExecutionStatus: gm.ExecutionStatus_FAILED,798 ScenarioItems: []*gm.ProtoItem{newStepItem(true, false, []*gm.Fragment{newTextFragment("Step1")})},799 },800 TableRowIndex: int32(0),801 },802 },803 {804 ItemType: gm.ProtoItem_TableDrivenScenario,805 TableDrivenScenario: &gm.ProtoTableDrivenScenario{806 Scenario: &gm.ProtoScenario{807 ScenarioHeading: "Scenario 1",808 ExecutionStatus: gm.ExecutionStatus_SKIPPED,809 ScenarioItems: []*gm.ProtoItem{newStepItem(true, false, []*gm.Fragment{newTextFragment("Step1")})},810 },811 TableRowIndex: int32(0),812 },813 },814 {815 ItemType: gm.ProtoItem_TableDrivenScenario,816 TableDrivenScenario: &gm.ProtoTableDrivenScenario{817 Scenario: &gm.ProtoScenario{818 ScenarioHeading: "Scenario 1",819 ExecutionStatus: gm.ExecutionStatus_PASSED,820 ScenarioItems: []*gm.ProtoItem{newStepItem(false, false, []*gm.Fragment{newTextFragment("Step1")})},821 },822 TableRowIndex: int32(1),823 },824 },825 },826 },827 }, "")828 if got.PassedScenarioCount != 1 {829 t.Errorf("Expected spec.PassedScenarioCount=1, got %d\n", got.PassedScenarioCount)830 }831 if got.SkippedScenarioCount != 1 {832 t.Errorf("Expected spec.SkippedScenarioCount=1, got %d\n", got.SkippedScenarioCount)833 }834 if got.FailedScenarioCount != 1 {835 t.Errorf("Expected spec.FailedScenarioCount=1, got %d\n", got.FailedScenarioCount)836 }837}838type summaryTest struct {839 name string840 result *spec841 expected summary842}843var summaryTests = []*summaryTest{844 {"All Passed",845 &spec{846 PassedScenarioCount: 2,847 SkippedScenarioCount: 0,848 FailedScenarioCount: 0,849 },850 summary{Failed: 0, Passed: 2, Skipped: 0, Total: 2},851 },852 {"With Skipped",853 &spec{854 PassedScenarioCount: 1,855 SkippedScenarioCount: 1,856 FailedScenarioCount: 0,857 },858 summary{Failed: 0, Passed: 1, Skipped: 1, Total: 2},859 },860 {"With failed",861 &spec{862 PassedScenarioCount: 1,863 SkippedScenarioCount: 0,864 FailedScenarioCount: 1,865 },866 summary{Failed: 1, Passed: 1, Skipped: 0, Total: 2},867 },868 {"With failed and skipped",869 &spec{870 PassedScenarioCount: 0,871 SkippedScenarioCount: 1,872 FailedScenarioCount: 1,873 },874 summary{Failed: 1, Passed: 0, Skipped: 1, Total: 2},875 },876}877func TestToScenarioSummary(t *testing.T) {878 for _, test := range summaryTests {879 want := test.expected880 got := *toScenarioSummary(test.result)881 checkEqual(t, test.name, want, got)882 }883}884func TestToScenario(t *testing.T) {885 want := &scenario{886 Heading: "Vowel counts in single word",887 ExecutionTime: "00:01:53",888 ExecutionStatus: pass,889 Tags: []string{"foo", "bar"},890 PreHookMessages: []string{"Before Scenario Message"},891 PostHookMessages: []string{"After Scenario Message"},892 Contexts: []item{893 {894 Kind: stepKind,895 Step: &step{896 Fragments: []*fragment{{FragmentKind: textFragmentKind, Text: "Context Step1"}},897 Result: &result{Status: pass, ExecutionTime: "00:03:31"},898 },899 },900 {901 Kind: stepKind,902 Step: &step{903 Fragments: []*fragment{{FragmentKind: textFragmentKind, Text: "Context Step2"}},904 Result: &result{Status: fail, ExecutionTime: "00:03:31"},905 },906 },907 },908 Items: []item{909 {910 Kind: commentKind,911 Comment: &comment{Text: "Comment0"},912 },913 {914 Kind: stepKind,915 Step: &step{916 Fragments: []*fragment{{FragmentKind: textFragmentKind, Text: "Step1"}},917 Result: &result{Status: fail, ExecutionTime: "00:03:31"},918 },919 },920 {921 Kind: commentKind,922 Comment: &comment{Text: "Comment1\n\nComment2"},923 },924 {925 Kind: stepKind,926 Step: &step{927 Fragments: []*fragment{{FragmentKind: textFragmentKind, Text: "Step2"}},928 Result: &result{Status: pass, ExecutionTime: "00:03:31"},929 },930 },931 {932 Kind: commentKind,933 Comment: &comment{Text: "Comment3"},934 },935 },936 Teardowns: []item{937 {938 Kind: stepKind,939 Step: &step{940 Fragments: []*fragment{{FragmentKind: textFragmentKind, Text: "Teardown Step1"}},941 Result: &result{Status: pass, ExecutionTime: "00:03:31"},942 },943 },944 {945 Kind: stepKind,946 Step: &step{947 Fragments: []*fragment{{FragmentKind: textFragmentKind, Text: "Teardown Step2"}},948 Result: &result{Status: fail, ExecutionTime: "00:03:31"},949 },950 },951 },952 TableRowIndex: -1,953 RetriesCount: 4,954 }955 got := toScenario(scn, -1)956 if !reflect.DeepEqual(got, want) {957 t.Errorf("want:\n%v\ngot:\n%v\n", want, got)958 }959}960func TestToScenarioWithHookFailures(t *testing.T) {961 screenShot := "Screenshot.png"962 want := &scenario{963 Heading: "Vowel counts in single word",964 ExecutionTime: "00:01:53",965 ExecutionStatus: fail,966 Contexts: []item{},967 Items: []item{968 {969 Kind: stepKind,970 Step: &step{971 Fragments: []*fragment{{FragmentKind: textFragmentKind, Text: "Step1"}},972 Result: &result{Status: fail, ExecutionTime: "00:03:31"},973 },974 },975 },976 Teardowns: []item{},977 BeforeScenarioHookFailure: newHookFailure("", "Before Scenario", "err", screenShot, "Stacktrace"),978 AfterScenarioHookFailure: newHookFailure("", "After Scenario", "err", screenShot, "Stacktrace"),979 TableRowIndex: -1,980 }981 got := toScenario(scnWithHookFailure, -1)982 checkEqual(t, "", want, got)983}984func TestToConcept(t *testing.T) {985 want := &concept{986 ConceptStep: &step{987 Fragments: []*fragment{988 {FragmentKind: textFragmentKind, Text: "Say "},989 {FragmentKind: dynamicFragmentKind, Text: "hello"},990 {FragmentKind: textFragmentKind, Text: " to "},991 {FragmentKind: tableFragmentKind,992 Table: &table{993 Headers: []string{"Word", "Count"},994 Rows: []*row{{Cells: []string{"Gauge", "3"}, Result: pass}, {Cells: []string{"Mingle", "2"}, Result: pass}},995 },996 },997 },998 Result: &result{Status: pass, ExecutionTime: "00:03:31"},999 },1000 Items: []item{1001 {1002 Kind: conceptKind,1003 Concept: &concept{1004 ConceptStep: &step{1005 Fragments: []*fragment{1006 {FragmentKind: textFragmentKind, Text: "Tell "},1007 {FragmentKind: dynamicFragmentKind, Text: "hello"},1008 },1009 Result: &result{Status: pass, ExecutionTime: "00:03:31"},1010 },1011 Items: []item{1012 {1013 Kind: stepKind,1014 Step: &step{1015 Fragments: []*fragment{{FragmentKind: textFragmentKind, Text: "Say Hi"}},1016 Result: &result{Status: pass, ExecutionTime: "00:03:31"},1017 },1018 },1019 },1020 },1021 },1022 {1023 Kind: stepKind,1024 Step: &step{1025 Fragments: []*fragment{1026 {FragmentKind: textFragmentKind, Text: "Say "},1027 {FragmentKind: staticFragmentKind, Text: "hi"},1028 {FragmentKind: textFragmentKind, Text: " to "},1029 {FragmentKind: dynamicFragmentKind, Text: "gauge"},1030 {FragmentKind: tableFragmentKind,1031 Table: &table{1032 Headers: []string{"Word", "Count"},1033 Rows: []*row{{Cells: []string{"Gauge", "3"}, Result: pass}, {Cells: []string{"Mingle", "2"}, Result: pass}},1034 },1035 },1036 },1037 Result: &result{Status: pass, ExecutionTime: "00:03:31"},1038 },1039 },1040 },1041 }1042 got := toConcept(protoConcept)1043 if !reflect.DeepEqual(got, want) {1044 t.Errorf("want:\n%v\ngot:\n%v\n", want, got)1045 }1046}1047func TestToStep(t *testing.T) {1048 want := &step{1049 Fragments: []*fragment{1050 {FragmentKind: textFragmentKind, Text: "Say "},1051 {FragmentKind: staticFragmentKind, Text: "hi"},1052 {FragmentKind: textFragmentKind, Text: " to "},1053 {FragmentKind: dynamicFragmentKind, Text: "gauge"},1054 {FragmentKind: tableFragmentKind,1055 Table: &table{1056 Headers: []string{"Word", "Count"},1057 Rows: []*row{{Cells: []string{"Gauge", "3"}, Result: pass}, {Cells: []string{"Mingle", "2"}, Result: pass}},1058 },1059 },1060 },1061 Result: &result{Status: skip, ExecutionTime: "00:03:31", SkippedReason: "Step impl not found"},1062 }1063 got := toStep(protoStep)1064 if !reflect.DeepEqual(got, want) {1065 t.Errorf("want:\n%v\ngot:\n%v\n", want, got)1066 }1067}1068func TestToStepCollectsScreenshot(t *testing.T) {1069 want := &step{1070 Fragments: []*fragment{1071 {FragmentKind: textFragmentKind, Text: "Say "},1072 {FragmentKind: staticFragmentKind, Text: "hi"},1073 {FragmentKind: textFragmentKind, Text: " to "},1074 {FragmentKind: dynamicFragmentKind, Text: "gauge"},1075 {FragmentKind: tableFragmentKind,1076 Table: &table{1077 Headers: []string{"Word", "Count"},1078 Rows: []*row{{Cells: []string{"Gauge", "3"}, Result: pass}, {Cells: []string{"Mingle", "2"}, Result: pass}},1079 },1080 },1081 },1082 Result: &result{1083 Status: skip,1084 ExecutionTime: "00:03:31",1085 SkippedReason: "Step impl not found",1086 ScreenshotFiles: []string{"screenshot1.png", "screenshot2.png"},1087 },1088 }1089 got := toStep(protoStepWithScreenshots)1090 if !reflect.DeepEqual(got, want) {1091 t.Errorf("want:\n%v\ngot:\n%v\n", want, got)1092 }1093}1094func TestToCSV(t *testing.T) {1095 table := newTableItem([]string{"Word", "Count"}, [][]string{1096 {"Gauge", "3"},1097 {"Mingle", "2"},1098 }).GetTable()1099 want := "Word,Count\n" +1100 "Gauge,3\n" +1101 "Mingle,2"1102 got := toCsv(table)1103 if !reflect.DeepEqual(got, want) {1104 t.Errorf("want:\n%q\ngot:\n%q\n", want, got)1105 }1106}1107func TestToStepWithSpecialParams(t *testing.T) {1108 want := &step{1109 Fragments: []*fragment{1110 {FragmentKind: textFragmentKind, Text: "Say "},1111 {FragmentKind: specialStringFragmentKind, Name: "file:foo.txt", Text: "hi", FileName: "foo.txt"},1112 {FragmentKind: textFragmentKind, Text: " to "},1113 {FragmentKind: specialTableFragmentKind,1114 Name: "table:myTable.csv",1115 Text: `Word,Count1116Gauge,31117Mingle,2`,1118 FileName: "myTable.csv",1119 },1120 },1121 Result: &result{1122 Status: pass,1123 ExecutionTime: "00:03:31",1124 },1125 }1126 got := toStep(protoStepWithSpecialParams)1127 if !reflect.DeepEqual(got, want) {1128 t.Errorf("want:\n%v\ngot:\n%v\n", want, got)1129 }1130}1131func TestToStepWithAfterHookFailure(t *testing.T) {1132 screenShot := "Screenshot.png"1133 want := &step{1134 Fragments: []*fragment{1135 {FragmentKind: textFragmentKind, Text: "Some Step"},1136 },1137 Result: &result{1138 Status: fail,1139 ExecutionTime: "00:03:31",1140 },1141 AfterStepHookFailure: newHookFailure("", "After Step", "err", screenShot, "Stacktrace"),1142 }1143 got := toStep(protoStepWithAfterHookFailure)1144 if !reflect.DeepEqual(got, want) {1145 t.Errorf("want:\n%v\ngot:\n%v\n", want, got)1146 }1147}1148func TestToComment(t *testing.T) {1149 want := &comment{Text: "Whatever"}1150 got := toComment(newCommentItem("Whatever").GetComment())1151 if !reflect.DeepEqual(got, want) {1152 t.Errorf("want:\n%q\ngot:\n%q\n", want, got)1153 }1154}1155func TestToHookFailure(t *testing.T) {1156 screenShot := newScreenshot()1157 want := newHookFailure("", "Before Suite", "java.lang.RuntimeException", screenShot, newStackTrace())1158 got := toHookFailure(failedHookFailure, "Before Suite")1159 if !reflect.DeepEqual(got, want) {1160 t.Errorf("want:\n%q\ngot:\n%q\n", want, got)1161 }1162}1163func TestToHookFailureWithNilInput(t *testing.T) {1164 var want *hookFailure = nil1165 got := toHookFailure(nil, "foobar")1166 if got != want {1167 t.Errorf("want:\n%q\ngot:\n%q\n", want, got)1168 }1169}1170type specNameGenerationTest struct {1171 specName string1172 projectRoot string1173 HTMLFilename string1174}1175var specNameGenerationTests = []*specNameGenerationTest{1176 {filepath.Join("Users", "gauge", "foo", "simple_specification.spec"), filepath.Join("Users", "gauge", "foo"), "simple_specification.html"},1177 {filepath.Join("Users", "gauge", "foo", "simple_specification.spec"), filepath.Join("Users", "gauge"), filepath.ToSlash(filepath.Join("foo", "simple_specification.html"))},1178 {"simple_specification.spec", "", "simple_specification.html"},1179 {filepath.Join("Users", "gauge", "foo", "abcd1234.spec"), filepath.Join("Users", "gauge", "foo"), "abcd1234.html"},1180 {filepath.Join("Users", "gauge", "foo", "bar", "simple_specification.spec"), filepath.Join("Users", "gauge", "foo"), filepath.ToSlash(filepath.Join("bar", "simple_specification.html"))},1181 {filepath.Join("Users", "gauge", "foo", "bar", "simple_specification.spec"), "Users", filepath.ToSlash(filepath.Join("gauge", "foo", "bar", "simple_specification.html"))},1182 {filepath.Join("Users", "gauge12", "fo_o", "b###$ar", "simple_specification.spec"), "Users", filepath.ToSlash(filepath.Join("gauge12", "fo_o", "b###$ar", "simple_specification.html"))},1183}1184func TestToHTMLFileName(t *testing.T) {1185 for _, test := range specNameGenerationTests {1186 got := toHTMLFileName(test.specName, test.projectRoot)1187 want := test.HTMLFilename1188 if got != want {1189 t.Errorf("want:\n%q\ngot:\n%q\n", want, got)1190 }1191 }1192}1193func TestGetSpecNameWhenHeadingIsPresent(t *testing.T) {1194 want := "heading"1195 got := getSpecName(&gm.ProtoSpec{SpecHeading: "heading"})1196 if got != want {1197 t.Errorf("want:\n%q\ngot:\n%q\n", want, got)1198 }1199}1200func TestGetSpecNameWhenHeadingIsNotPresent(t *testing.T) {1201 want := "example.spec"1202 got := getSpecName(&gm.ProtoSpec{FileName: filepath.Join("specs", "specs1", "example.spec")})1203 if got != want {1204 t.Errorf("want:\n%q\ngot:\n%q\n", want, got)1205 }1206}1207type tableDrivenStatusComputeTest struct {1208 name string1209 spec *spec1210 status status1211}1212var tableDrivenStatusComputeTests = []*tableDrivenStatusComputeTest{1213 {"all passed",1214 &spec{Datatable: &table{Headers: []string{"foo"}, Rows: []*row{{Cells: []string{"foo1"}}}},1215 Scenarios: []*scenario{1216 {ExecutionStatus: pass, TableRowIndex: 0},1217 {ExecutionStatus: pass, TableRowIndex: 0},1218 }},1219 pass},1220 {"pass and fail",1221 &spec{Datatable: &table{Headers: []string{"foo"}, Rows: []*row{{Cells: []string{"foo1"}}}},1222 Scenarios: []*scenario{1223 {ExecutionStatus: pass, TableRowIndex: 0},1224 {ExecutionStatus: fail, TableRowIndex: 0},1225 }},1226 fail},1227 {"pass and skip",1228 &spec{Datatable: &table{Headers: []string{"foo"}, Rows: []*row{{Cells: []string{"foo1"}}}},1229 Scenarios: []*scenario{1230 {ExecutionStatus: pass, TableRowIndex: 0},1231 {ExecutionStatus: skip, TableRowIndex: 0},1232 }},1233 pass},1234 {"skip and fail",1235 &spec{Datatable: &table{Headers: []string{"foo"}, Rows: []*row{{Cells: []string{"foo1"}}}},1236 Scenarios: []*scenario{1237 {ExecutionStatus: skip, TableRowIndex: 0},1238 {ExecutionStatus: fail, TableRowIndex: 0},1239 }},1240 fail},1241 {"all fail",1242 &spec{Datatable: &table{Headers: []string{"foo"}, Rows: []*row{{Cells: []string{"foo1"}}}},1243 Scenarios: []*scenario{1244 {ExecutionStatus: fail, TableRowIndex: 0},1245 {ExecutionStatus: fail, TableRowIndex: 0},1246 }},1247 fail},1248 {"all skip",1249 &spec{Datatable: &table{Headers: []string{"foo"}, Rows: []*row{{Cells: []string{"foo1"}}}},1250 Scenarios: []*scenario{1251 {ExecutionStatus: skip, TableRowIndex: 0},1252 {ExecutionStatus: skip, TableRowIndex: 0},1253 }},1254 skip},1255 {"spec before hook fail",1256 &spec{BeforeSpecHookFailures: []*hookFailure{1257 {HookName: "Some failure", TableRowIndex: 0},1258 }, Datatable: &table{Headers: []string{"foo"}, Rows: []*row{{Cells: []string{"foo1"}}}},1259 Scenarios: []*scenario{1260 {ExecutionStatus: pass, TableRowIndex: 0},1261 }},1262 fail},1263 {"spec after hook fail",1264 &spec{AfterSpecHookFailures: []*hookFailure{1265 {HookName: "Some failure", TableRowIndex: 0},1266 }, Datatable: &table{Headers: []string{"foo"}, Rows: []*row{{Cells: []string{"foo1"}}}},1267 Scenarios: []*scenario{1268 {ExecutionStatus: pass, TableRowIndex: 0},1269 }},1270 fail},1271}1272func TestTableDrivenStatusCompute(t *testing.T) {1273 for _, test := range tableDrivenStatusComputeTests {1274 want := test.status1275 computeTableDrivenStatuses(test.spec)1276 got := test.spec.Datatable.Rows[0].Result1277 if want != got {1278 t.Errorf("test: %s want:\n%q\ngot:\n%q\n", test.name, want, got)1279 }1280 }1281}1282func TestMapProjectNametoSuiteResult(t *testing.T) {1283 psr := &gm.ProtoSuiteResult{ProjectName: "foo"}1284 res := ToSuiteResult("", psr)1285 if res.ProjectName != "foo" {1286 t.Errorf("Expected ProjectName=foo, got %s", res.ProjectName)1287 }1288}1289func TestMapEnvironmenttoSuiteResult(t *testing.T) {1290 psr := &gm.ProtoSuiteResult{Environment: "foo"}1291 res := ToSuiteResult("", psr)1292 if res.Environment != "foo" {1293 t.Errorf("Expected Environment=foo, got %s", res.Environment)1294 }1295}1296func TestMapTagstoSuiteResult(t *testing.T) {1297 psr := &gm.ProtoSuiteResult{Tags: "foo, bar"}1298 res := ToSuiteResult("", psr)1299 if res.Tags != "foo, bar" {1300 t.Errorf("Expected Tags=foo, bar; got %s", res.Tags)1301 }1302}1303func TestMapExecutionTimeToSuiteResult(t *testing.T) {1304 psr := &gm.ProtoSuiteResult{ExecutionTime: 113163}1305 res := ToSuiteResult("", psr)1306 if res.ExecutionTime != 113163 {1307 t.Errorf("Expected ExecutionTime=113163; got %d", res.ExecutionTime)1308 }1309}1310func TestSpecsCountToSuiteResult(t *testing.T) {1311 psr := &gm.ProtoSuiteResult{SpecsFailedCount: 2, SpecsSkippedCount: 1, SpecResults: []*gm.ProtoSpecResult{1312 {Skipped: false, Failed: false, ProtoSpec: &gm.ProtoSpec{FileName: "spec-file-1.spec"}},1313 {Skipped: false, Failed: true, ProtoSpec: &gm.ProtoSpec{FileName: "spec-file-2.spec"}},1314 {Skipped: true, Failed: false, ProtoSpec: &gm.ProtoSpec{FileName: "spec-file-3.spec"}},1315 {Skipped: false, Failed: true, ProtoSpec: &gm.ProtoSpec{FileName: "spec-file-4.spec"}},1316 {Skipped: false, Failed: false, ProtoSpec: &gm.ProtoSpec{FileName: "spec-file-5.spec"}},1317 {Skipped: false, Failed: false, ProtoSpec: &gm.ProtoSpec{FileName: "spec-file-6.spec"}},1318 }}1319 res := ToSuiteResult("", psr)1320 if res.PassedSpecsCount != 3 {1321 t.Errorf("Expected PassedSpecsCount=3; got %d\n", res.PassedSpecsCount)1322 }1323 if res.SkippedSpecsCount != 1 {1324 t.Errorf("Expected SkippedSpecsCount=3; got %d\n", res.SkippedSpecsCount)1325 }1326 if res.FailedSpecsCount != 2 {1327 t.Errorf("Expected FailedSpecsCount=3; got %d\n", res.FailedSpecsCount)1328 }1329}1330func TestScenarioCountToSuiteResult(t *testing.T) {1331 psr := &gm.ProtoSuiteResult{SpecResults: []*gm.ProtoSpecResult{1332 {ScenarioCount: 3, ScenarioFailedCount: 2, ProtoSpec: &gm.ProtoSpec{FileName: "spec-file-1.spec"}},1333 {ScenarioCount: 3, ScenarioSkippedCount: 1, ProtoSpec: &gm.ProtoSpec{FileName: "spec-file-2.spec"}},1334 {ScenarioCount: 3, ScenarioSkippedCount: 1, ScenarioFailedCount: 2, ProtoSpec: &gm.ProtoSpec{FileName: "spec-file-3.spec"}},1335 }}1336 res := ToSuiteResult("", psr)1337 if res.PassedScenarioCount != 3 {1338 t.Errorf("Expected PassedSpecsCount=3; got %d\n", res.PassedScenarioCount)1339 }1340 if res.SkippedScenarioCount != 2 {1341 t.Errorf("Expected SkippedSpecsCount=3; got %d\n", res.SkippedScenarioCount)1342 }1343 if res.FailedScenarioCount != 4 {1344 t.Errorf("Expected FailedSpecsCount=3; got %d\n", res.FailedScenarioCount)1345 }1346}1347func TestToSuiteResultShouldNormalizeSpecFilepath(t *testing.T) {1348 projectRoot := filepath.Join(string(os.PathSeparator), "user", "user-name", "work", "gauge-project")1349 psr := &gm.ProtoSuiteResult{SpecsFailedCount: 2, SpecsSkippedCount: 1, SpecResults: []*gm.ProtoSpecResult{1350 {ProtoSpec: &gm.ProtoSpec{FileName: "/user/user-name/work/common-specs/specs/spec-file-1.spec"}},1351 }}1352 res := ToSuiteResult(projectRoot, psr)1353 ecpectedFilePath := filepath.Join(projectRoot, "common-specs", "specs", "spec-file-1.spec")1354 if res.SpecResults[0].FileName != ecpectedFilePath {1355 t.Errorf("Expected normalized spec file path to be : %s; got %s\n", ecpectedFilePath, res.SpecResults[0].FileName)1356 }1357}1358func TestMapPreHookFailureToSuiteResult(t *testing.T) {1359 psr := &gm.ProtoSuiteResult{PreHookFailure: &gm.ProtoHookFailure{ErrorMessage: "foo failure"}}1360 res := ToSuiteResult("", psr)1361 if res.BeforeSuiteHookFailure == nil {1362 t.Errorf("Expected BeforeSuiteHookFailure not nil\n")1363 }1364 if res.BeforeSuiteHookFailure.ErrMsg != "foo failure" {1365 t.Errorf("Expected BeforeSuiteHookFailure.Message= 'foo failure', got %s\n", res.BeforeSuiteHookFailure.ErrMsg)1366 }1367}1368func TestMapPostHookFailureToSuiteResult(t *testing.T) {1369 psr := &gm.ProtoSuiteResult{PostHookFailure: &gm.ProtoHookFailure{ErrorMessage: "foo failure"}}1370 res := ToSuiteResult("", psr)1371 if res.AfterSuiteHookFailure == nil {1372 t.Errorf("Expected AfterSuiteHookFailure not nil\n")1373 }1374 if res.AfterSuiteHookFailure.ErrMsg != "foo failure" {1375 t.Errorf("Expected AfterSuiteHookFailure.Message= 'foo failure', got %s\n", res.AfterSuiteHookFailure.ErrMsg)1376 }1377}1378func TestMapPreHookMessagesToSuiteResult(t *testing.T) {1379 psr := &gm.ProtoSuiteResult{PreHookMessages: []string{"Before Suite Message"}}1380 res := ToSuiteResult("", psr)1381 if len(res.PreHookMessages) != 1 {1382 t.Errorf("Expected PreHookMessages length to be 1\n")1383 }1384 if res.PreHookMessages[0] != "Before Suite Message" {1385 t.Errorf("Expected PreHookMessage[0] = 'Before Suite Message', got %s\n", res.PreHookMessages[0])1386 }1387}1388func TestMapPostHookMessagesToSuiteResult(t *testing.T) {1389 psr := &gm.ProtoSuiteResult{PostHookMessages: []string{"After Suite Message"}}1390 res := ToSuiteResult("", psr)1391 if len(res.PostHookMessages) != 1 {1392 t.Errorf("Expected PostHookMessages length to be 1\n")1393 }1394 if res.PostHookMessages[0] != "After Suite Message" {1395 t.Errorf("Expected PostHookMessage[0] = 'After Suite Message', got %s\n", res.PostHookMessages[0])1396 }1397}1398func TestMapTimestampToSuiteResult(t *testing.T) {1399 timestamp := "Jun 3, 2016 at 12:29pm"1400 psr := &gm.ProtoSuiteResult{Timestamp: timestamp}1401 res := ToSuiteResult("", psr)1402 if res.Timestamp != timestamp {1403 t.Errorf("Expected Timestamp=%s; got %s\n", timestamp, res.Timestamp)1404 }1405}1406func TestMapExecutionStatusPassByDefaultToSuiteResult(t *testing.T) {1407 psr := &gm.ProtoSuiteResult{}1408 res := ToSuiteResult("", psr)1409 if res.ExecutionStatus != pass {1410 t.Errorf("Expected ExecutionStatus=pass, got %s\n", res.ExecutionStatus)1411 }1412}1413func TestMapExecutionStatusOnFailureToSuiteResult(t *testing.T) {1414 psr := &gm.ProtoSuiteResult{Failed: true}1415 res := ToSuiteResult("", psr)1416 if res.ExecutionStatus != fail {1417 t.Errorf("Expected ExecutionStatus=fail, got %s\n", res.ExecutionStatus)1418 }1419}1420func TestMapSpecResultsToSuiteResult(t *testing.T) {1421 psr := &gm.ProtoSuiteResult{1422 SpecResults: []*gm.ProtoSpecResult{1423 {ProtoSpec: &gm.ProtoSpec{FileName: "foo.spec", SpecHeading: "Foo Spec"}},1424 {ProtoSpec: &gm.ProtoSpec{FileName: "bar.spec", SpecHeading: "Boo Spec"}},1425 {ProtoSpec: &gm.ProtoSpec{FileName: "baz.spec", SpecHeading: "Baz Spec"}},1426 },1427 }1428 res := ToSuiteResult("", psr)1429 if len(res.SpecResults) != 3 {1430 t.Errorf("Expected 3 spec results, got %d\n", len(res.SpecResults))1431 }1432 for i, s := range res.SpecResults {1433 wantFileName := psr.GetSpecResults()[i].GetProtoSpec().GetFileName()1434 gotFileName := s.FileName1435 if wantFileName != gotFileName {1436 t.Errorf("Spec Filename Mismatch, want '%s', got '%s'", wantFileName, gotFileName)1437 }1438 }1439}1440func TestToNestedSuiteResultMapsProjectName(t *testing.T) {1441 want := "foo"1442 sr := &SuiteResult{ProjectName: want}1443 got := toNestedSuiteResult("some/path", sr)1444 if got.ProjectName != want {1445 t.Fatalf("Expected ProjectName=%s, got %s", want, got.ProjectName)1446 }1447}1448func TestToNestedSuiteResultMapsTimeStamp(t *testing.T) {1449 want := "Jul 13, 2016 at 11:49am"1450 sr := &SuiteResult{Timestamp: want}1451 got := toNestedSuiteResult("some/path", sr)1452 if got.Timestamp != want {1453 t.Fatalf("Expected TimeStamp=%s, got %s", want, got.Timestamp)1454 }1455}1456func TestToNestedSuiteResultMapsEnvironment(t *testing.T) {1457 want := "foo"1458 sr := &SuiteResult{Environment: want}1459 got := toNestedSuiteResult("some/path", sr)1460 if got.Environment != want {1461 t.Fatalf("Expected Environment=%s, got %s", want, got.Environment)1462 }1463}1464func TestToNestedSuiteResultMapsTags(t *testing.T) {1465 want := "tag1, tag2"1466 sr := &SuiteResult{Tags: want}1467 got := toNestedSuiteResult("some/path", sr)1468 if got.Tags != want {1469 t.Fatalf("Expected Tags=%s, got %s", want, got.Tags)1470 }1471}1472func TestToNestedSuiteResultMapsBeforeSuiteHookFailure(t *testing.T) {1473 want := "fooHookFailure"1474 sr := &SuiteResult{BeforeSuiteHookFailure: &hookFailure{HookName: want}}1475 got := toNestedSuiteResult("some/path", sr)1476 if got.BeforeSuiteHookFailure == nil {1477 t.Fatal("Expected BeforeSuiteHookFailure to be not nil")1478 }1479 if got.BeforeSuiteHookFailure.HookName != want {1480 t.Fatalf("expected BeforeSuiteHookFailure to have HookName = %s, got %s", want, got.BeforeSuiteHookFailure.HookName)1481 }1482}1483func TestToNestedSuiteResultMapsAfterSuiteHookFailure(t *testing.T) {1484 want := "fooHookFailure"1485 sr := &SuiteResult{AfterSuiteHookFailure: &hookFailure{HookName: want}}1486 got := toNestedSuiteResult("some/path", sr)1487 if got.AfterSuiteHookFailure == nil {1488 t.Fatal("Expected AfterSuiteHookFailure to be not nil")1489 }1490 if got.AfterSuiteHookFailure.HookName != want {1491 t.Fatalf("expected AfterSuiteHookFailure to have HookName = %s, got %s", want, got.AfterSuiteHookFailure.HookName)1492 }1493}1494func TestToNestedSuiteResultMapsExecutionTime(t *testing.T) {1495 want := int64(2000)1496 sr := &SuiteResult{SpecResults: []*spec{1497 {FileName: "nested1/foo.spec", SpecHeading: "Foo Spec", ExecutionTime: 1000},1498 {FileName: "nested1/nested2/boo.spec", SpecHeading: "Boo Spec", ExecutionTime: 1000},1499 {FileName: "bar.spec", SpecHeading: "Bar Spec", ExecutionTime: 1000},1500 }}1501 got := toNestedSuiteResult("nested1", sr)1502 if got.ExecutionTime != want {1503 t.Fatalf("expected ExecutionTime = %d, got %d", want, got.ExecutionTime)1504 }1505}1506func TestToNestedSuiteResultMapsPassedCount(t *testing.T) {1507 want := 11508 sr := &SuiteResult{SpecResults: []*spec{1509 {FileName: "nested1/foo.spec", SpecHeading: "Foo Spec", ExecutionStatus: pass},1510 {FileName: "nested1/nested2/boo.spec", SpecHeading: "Boo Spec", ExecutionStatus: skip},1511 {FileName: "bar.spec", SpecHeading: "Bar Spec", ExecutionStatus: pass},1512 }}1513 got := toNestedSuiteResult("nested1", sr)1514 if got.PassedSpecsCount != want {1515 t.Fatalf("Expected FailedCount=%d, got %d", want, got.PassedSpecsCount)1516 }1517}1518func TestToNestedSuiteResultMapsFailedCount(t *testing.T) {1519 want := 11520 sr := &SuiteResult{SpecResults: []*spec{1521 {FileName: "nested1/foo.spec", SpecHeading: "Foo Spec", ExecutionStatus: pass},1522 {FileName: "nested1/nested2/boo.spec", SpecHeading: "Boo Spec", ExecutionStatus: fail},1523 {FileName: "nested1/bar.spec", SpecHeading: "Bar Spec", ExecutionStatus: pass},1524 }}1525 got := toNestedSuiteResult("nested1", sr)1526 if got.FailedSpecsCount != want {1527 t.Fatalf("Expected FailedCount=%d, got %d", want, got.FailedSpecsCount)1528 }1529}1530func TestToNestedSuiteResultMapsSkippedCount(t *testing.T) {1531 want := 21532 sr := &SuiteResult{SpecResults: []*spec{1533 {FileName: "nested1/foo.spec", SpecHeading: "Foo Spec", ExecutionStatus: skip},1534 {FileName: "nested1/nested2/boo.spec", SpecHeading: "Boo Spec", ExecutionStatus: skip},1535 {FileName: "nested1/bar.spec", SpecHeading: "Bar Spec", ExecutionStatus: fail},1536 }}1537 got := toNestedSuiteResult("nested1", sr)1538 if got.SkippedSpecsCount != want {1539 t.Fatalf("Expected SkippedCount=%d, got %d", want, got.SkippedSpecsCount)1540 }1541}1542func TestToNestedSuiteResultMapsSuccessRate(t *testing.T) {1543 want := float32(50.0)1544 sr := &SuiteResult{SpecResults: []*spec{1545 {FileName: "nested1/foo.spec", SpecHeading: "Foo Spec", ExecutionStatus: fail},1546 {FileName: "nested1/nested2/boo.spec", SpecHeading: "Boo Spec", ExecutionStatus: skip},1547 {FileName: "nested1/nested2/bar.spec", SpecHeading: "Bar Spec", ExecutionStatus: pass},1548 {FileName: "nested1/bar.spec", SpecHeading: "Baz Spec", ExecutionStatus: pass},1549 }}1550 got := toNestedSuiteResult("nested1", sr)1551 if got.SuccessRate != want {1552 t.Fatalf("Expected SuccessRate=%f, got %f", want, got.SuccessRate)1553 }1554}1555func TestToNestedSuiteResultMapsSpecResults(t *testing.T) {1556 fooSpec := spec{FileName: "nested1/foo.spec", SpecHeading: "Foo Spec"}1557 booSpec := spec{FileName: "nested1/nested2/boo.spec", SpecHeading: "Boo Spec"}1558 barSpec := spec{FileName: "nested1/bar.spec", SpecHeading: "Bar Spec"}1559 bazSpec := spec{FileName: "nested2/nested1/baz.spec", SpecHeading: "Baz Spec"}1560 specResults := []*spec{1561 &fooSpec,1562 &booSpec,1563 &bazSpec,1564 &barSpec,1565 }1566 got := toNestedSuiteResult("nested1", &SuiteResult{SpecResults: specResults})1567 want := []*spec{1568 &fooSpec,1569 &booSpec,1570 &barSpec,1571 }1572 checkEqual(t, "", want, got.SpecResults)1573}1574func TestToSuiteResultMapsSpecResultsGreaterThanBufferSize(t *testing.T) {1575 psr := &gm.ProtoSuiteResult{1576 SpecResults: []*gm.ProtoSpecResult{1577 {ProtoSpec: &gm.ProtoSpec{FileName: "foo.spec", SpecHeading: "Foo Spec"}},1578 {ProtoSpec: &gm.ProtoSpec{FileName: "bar.spec", SpecHeading: "Boo Spec"}},1579 {ProtoSpec: &gm.ProtoSpec{FileName: "baz.spec", SpecHeading: "Baz Spec"}},1580 {ProtoSpec: &gm.ProtoSpec{FileName: "foo.spec", SpecHeading: "Foo Spec"}},1581 {ProtoSpec: &gm.ProtoSpec{FileName: "bar.spec", SpecHeading: "Boo Spec"}},1582 {ProtoSpec: &gm.ProtoSpec{FileName: "baz.spec", SpecHeading: "Baz Spec"}},1583 {ProtoSpec: &gm.ProtoSpec{FileName: "foo.spec", SpecHeading: "Foo Spec"}},1584 {ProtoSpec: &gm.ProtoSpec{FileName: "bar.spec", SpecHeading: "Boo Spec"}},1585 {ProtoSpec: &gm.ProtoSpec{FileName: "baz.spec", SpecHeading: "Baz Spec"}},1586 {ProtoSpec: &gm.ProtoSpec{FileName: "foo.spec", SpecHeading: "Foo Spec"}},1587 {ProtoSpec: &gm.ProtoSpec{FileName: "bar.spec", SpecHeading: "Boo Spec"}},1588 {ProtoSpec: &gm.ProtoSpec{FileName: "baz.spec", SpecHeading: "Baz Spec"}},1589 },1590 }1591 res := ToSuiteResult("", psr)1592 if len(res.SpecResults) != 12 {1593 t.Errorf("Expected 12 spec results, got %d\n", len(res.SpecResults))1594 }1595 for i, s := range res.SpecResults {1596 wantFileName := psr.GetSpecResults()[i].GetProtoSpec().GetFileName()1597 gotFileName := s.FileName1598 if wantFileName != gotFileName {1599 t.Errorf("Spec Filename Mismatch, want '%s', got '%s'", wantFileName, gotFileName)1600 }1601 }1602}1603func BenchmarkToSuite(b *testing.B) {1604 ps := &gm.ProtoSuiteResult{1605 Chunked: true,1606 SpecResults: []*gm.ProtoSpecResult{},1607 }1608 for i := 0; i < b.N; i++ {1609 ps.SpecResults = append(ps.SpecResults, passSpecResWithScreenshots)1610 }1611 ToSuiteResult(".", ps)1612}...

Full Screen

Full Screen

merge_test.go

Source:merge_test.go Github

copy

Full Screen

1/*----------------------------------------------------------------2 * Copyright (c) ThoughtWorks, Inc.3 * Licensed under the Apache License, Version 2.04 * See LICENSE in the project root for license information.5 *----------------------------------------------------------------*/6package execution7import (8 "testing"9 "reflect"10 gm "github.com/getgauge/gauge-proto/go/gauge_messages"11 "github.com/getgauge/gauge/execution/result"12)13type stat struct {14 failed int15 skipped int16 total int17}18var statsTests = []struct {19 status gm.ExecutionStatus20 want stat21 message string22}{23 {gm.ExecutionStatus_FAILED, stat{failed: 1, total: 1}, "Scenario Failure"},24 {gm.ExecutionStatus_SKIPPED, stat{skipped: 1, total: 1}, "Scenario Skipped"},25 {gm.ExecutionStatus_PASSED, stat{total: 1}, "Scenario Passed"},26}27func TestModifySpecStats(t *testing.T) {28 for _, test := range statsTests {29 res := &result.SpecResult{}30 modifySpecStats(&gm.ProtoScenario{ExecutionStatus: test.status}, res)31 got := stat{failed: res.ScenarioFailedCount, skipped: res.ScenarioSkippedCount, total: res.ScenarioCount}32 if !reflect.DeepEqual(got, test.want) {33 t.Errorf("Modify spec stats failed for %s. Want: %v , Got: %v", test.message, test.want, got)34 }35 }36}37func TestAggregateDataTableScnStats(t *testing.T) {38 res := &result.SpecResult{}39 scns := map[string][]*gm.ProtoTableDrivenScenario{40 "heading1": {41 {Scenario: &gm.ProtoScenario{ExecutionStatus: gm.ExecutionStatus_PASSED}},42 {Scenario: &gm.ProtoScenario{ExecutionStatus: gm.ExecutionStatus_FAILED}},43 {Scenario: &gm.ProtoScenario{44 ExecutionStatus: gm.ExecutionStatus_SKIPPED,45 SkipErrors: []string{"--table-rows"},46 }},47 },48 "heading2": {{Scenario: &gm.ProtoScenario{49 ExecutionStatus: gm.ExecutionStatus_SKIPPED,50 SkipErrors: []string{""},51 }}},52 "heading3": {{Scenario: &gm.ProtoScenario{ExecutionStatus: gm.ExecutionStatus_PASSED}}},53 "heading4": {{Scenario: &gm.ProtoScenario{ExecutionStatus: gm.ExecutionStatus_FAILED}}},54 }55 aggregateDataTableScnStats(scns, res)56 got := stat{failed: res.ScenarioFailedCount, skipped: res.ScenarioSkippedCount, total: res.ScenarioCount}57 want := stat{failed: 2, skipped: 1, total: 5}58 if !reflect.DeepEqual(got, want) {59 t.Errorf("Aggregate data table scenario stats failed. Want: %v , Got: %v", want, got)60 }61}62func TestMergeResults(t *testing.T) {63 got := mergeResults([]*result.SpecResult{64 {65 ProtoSpec: &gm.ProtoSpec{66 SpecHeading: "heading", FileName: "filename", Tags: []string{"tags"},67 Items: []*gm.ProtoItem{68 {ItemType: gm.ProtoItem_Table, Table: &gm.ProtoTable{Headers: &gm.ProtoTableRow{Cells: []string{"a"}}, Rows: []*gm.ProtoTableRow{{Cells: []string{"d"}}}}},69 {ItemType: gm.ProtoItem_Scenario, Scenario: &gm.ProtoScenario{ExecutionStatus: gm.ExecutionStatus_PASSED, ScenarioHeading: "scenario Heading1"}},70 {71 ItemType: gm.ProtoItem_TableDrivenScenario, TableDrivenScenario: &gm.ProtoTableDrivenScenario{72 Scenario: &gm.ProtoScenario{ExecutionStatus: gm.ExecutionStatus_PASSED, ScenarioHeading: "scenario Heading2"},73 TableRowIndex: 2,74 },75 },76 },77 }, ExecutionTime: int64(1),78 },79 {80 ProtoSpec: &gm.ProtoSpec{81 SpecHeading: "heading", FileName: "filename", Tags: []string{"tags"},82 Items: []*gm.ProtoItem{83 {ItemType: gm.ProtoItem_Table, Table: &gm.ProtoTable{Headers: &gm.ProtoTableRow{Cells: []string{"a"}}, Rows: []*gm.ProtoTableRow{{Cells: []string{"b"}}}}},84 {85 ItemType: gm.ProtoItem_TableDrivenScenario, TableDrivenScenario: &gm.ProtoTableDrivenScenario{86 Scenario: &gm.ProtoScenario{ExecutionStatus: gm.ExecutionStatus_PASSED, ScenarioHeading: "scenario Heading2"},87 TableRowIndex: 0,88 },89 },90 },91 }, ExecutionTime: int64(2),92 },93 {94 ProtoSpec: &gm.ProtoSpec{95 SpecHeading: "heading", FileName: "filename", Tags: []string{"tags"},96 Items: []*gm.ProtoItem{97 {ItemType: gm.ProtoItem_Table, Table: &gm.ProtoTable{Headers: &gm.ProtoTableRow{Cells: []string{"a"}}, Rows: []*gm.ProtoTableRow{{Cells: []string{"c"}}}}},98 {99 ItemType: gm.ProtoItem_TableDrivenScenario, TableDrivenScenario: &gm.ProtoTableDrivenScenario{100 Scenario: &gm.ProtoScenario{ExecutionStatus: gm.ExecutionStatus_PASSED, ScenarioHeading: "scenario Heading2"},101 TableRowIndex: 1,102 },103 },104 },105 }, ExecutionTime: int64(2),106 },107 })108 want := &result.SpecResult{109 ProtoSpec: &gm.ProtoSpec{110 SpecHeading: "heading", FileName: "filename", Tags: []string{"tags"},111 Items: []*gm.ProtoItem{112 {ItemType: gm.ProtoItem_Table, Table: &gm.ProtoTable{Headers: &gm.ProtoTableRow{Cells: []string{"a"}}, Rows: []*gm.ProtoTableRow{{Cells: []string{"d"}}, {Cells: []string{"b"}}, {Cells: []string{"c"}}}}},113 {ItemType: gm.ProtoItem_Scenario, Scenario: &gm.ProtoScenario{ExecutionStatus: gm.ExecutionStatus_PASSED, ScenarioHeading: "scenario Heading1"}},114 {115 ItemType: gm.ProtoItem_TableDrivenScenario, TableDrivenScenario: &gm.ProtoTableDrivenScenario{116 Scenario: &gm.ProtoScenario{ExecutionStatus: gm.ExecutionStatus_PASSED, ScenarioHeading: "scenario Heading2"},117 TableRowIndex: 0,118 },119 },120 {121 ItemType: gm.ProtoItem_TableDrivenScenario, TableDrivenScenario: &gm.ProtoTableDrivenScenario{122 Scenario: &gm.ProtoScenario{ExecutionStatus: gm.ExecutionStatus_PASSED, ScenarioHeading: "scenario Heading2"},123 TableRowIndex: 1,124 },125 },126 {127 ItemType: gm.ProtoItem_TableDrivenScenario, TableDrivenScenario: &gm.ProtoTableDrivenScenario{128 Scenario: &gm.ProtoScenario{ExecutionStatus: gm.ExecutionStatus_PASSED, ScenarioHeading: "scenario Heading2"},129 TableRowIndex: 2,130 },131 },132 }, IsTableDriven: false,133 },134 ScenarioCount: 4, ScenarioSkippedCount: 0, ScenarioFailedCount: 0, IsFailed: false, Skipped: false, ExecutionTime: int64(5),135 }136 if !reflect.DeepEqual(got, want) {137 t.Errorf("Merge data table spec results failed.\n\tWant: %v\n\tGot: %v", want, got)138 }139}140func TestMergeResultsWithPreHookFailure(t *testing.T) {141 got := mergeResults([]*result.SpecResult{142 {143 ProtoSpec: &gm.ProtoSpec{144 PreHookFailures: []*gm.ProtoHookFailure{{StackTrace: "stacktrace"}},145 SpecHeading: "heading", FileName: "filename", Tags: []string{"tags"},146 Items: []*gm.ProtoItem{147 {ItemType: gm.ProtoItem_Table, Table: &gm.ProtoTable{Headers: &gm.ProtoTableRow{Cells: []string{"a"}}, Rows: []*gm.ProtoTableRow{{Cells: []string{"b"}}}}},148 },149 }, ExecutionTime: int64(1),150 },151 {152 ProtoSpec: &gm.ProtoSpec{153 PreHookFailures: []*gm.ProtoHookFailure{{StackTrace: "stacktrace1"}},154 SpecHeading: "heading", FileName: "filename", Tags: []string{"tags"},155 Items: []*gm.ProtoItem{156 {ItemType: gm.ProtoItem_Table, Table: &gm.ProtoTable{Headers: &gm.ProtoTableRow{Cells: []string{"a"}}, Rows: []*gm.ProtoTableRow{{Cells: []string{"d"}}}}},157 },158 }, ExecutionTime: int64(2),159 },160 {161 ProtoSpec: &gm.ProtoSpec{162 PreHookFailures: []*gm.ProtoHookFailure{{StackTrace: "stacktrace2"}},163 SpecHeading: "heading", FileName: "filename", Tags: []string{"tags"},164 Items: []*gm.ProtoItem{165 {ItemType: gm.ProtoItem_Table, Table: &gm.ProtoTable{Headers: &gm.ProtoTableRow{Cells: []string{"a"}}, Rows: []*gm.ProtoTableRow{{Cells: []string{"c"}}}}},166 },167 }, ExecutionTime: int64(2),168 },169 })170 want := &result.SpecResult{171 ProtoSpec: &gm.ProtoSpec{172 PreHookFailures: []*gm.ProtoHookFailure{{StackTrace: "stacktrace"}, {StackTrace: "stacktrace1", TableRowIndex: 1}, {StackTrace: "stacktrace2", TableRowIndex: 2}},173 SpecHeading: "heading", FileName: "filename", Tags: []string{"tags"},174 Items: []*gm.ProtoItem{175 {ItemType: gm.ProtoItem_Table, Table: &gm.ProtoTable{Headers: &gm.ProtoTableRow{Cells: []string{"a"}}, Rows: []*gm.ProtoTableRow{{Cells: []string{"b"}}, {Cells: []string{"d"}}, {Cells: []string{"c"}}}}},176 }, IsTableDriven: false,177 },178 ScenarioCount: 0, ScenarioSkippedCount: 0, ScenarioFailedCount: 0, IsFailed: false, Skipped: false, ExecutionTime: int64(5),179 }180 if !reflect.DeepEqual(got, want) {181 t.Errorf("Merge data table spec results failed.\n\tWant: %v\n\tGot: %v", want, got)182 }183}184func TestMergeSkippedResults(t *testing.T) {185 got := mergeResults([]*result.SpecResult{186 {187 ProtoSpec: &gm.ProtoSpec{188 SpecHeading: "heading", FileName: "filename", Tags: []string{"tags"},189 Items: []*gm.ProtoItem{190 {ItemType: gm.ProtoItem_Table, Table: &gm.ProtoTable{Headers: &gm.ProtoTableRow{Cells: []string{"a"}}, Rows: []*gm.ProtoTableRow{{Cells: []string{"b"}}}}},191 {ItemType: gm.ProtoItem_Scenario, Scenario: &gm.ProtoScenario{ExecutionStatus: gm.ExecutionStatus_SKIPPED, ScenarioHeading: "scenario Heading1", SkipErrors: []string{"error"}}},192 {193 ItemType: gm.ProtoItem_TableDrivenScenario, TableDrivenScenario: &gm.ProtoTableDrivenScenario{194 Scenario: &gm.ProtoScenario{ExecutionStatus: gm.ExecutionStatus_SKIPPED, ScenarioHeading: "scenario Heading2", SkipErrors: []string{"error"}},195 TableRowIndex: 0,196 },197 },198 },199 }, ExecutionTime: int64(1),200 Skipped: true,201 },202 {203 ProtoSpec: &gm.ProtoSpec{204 SpecHeading: "heading", FileName: "filename", Tags: []string{"tags"},205 Items: []*gm.ProtoItem{206 {ItemType: gm.ProtoItem_Table, Table: &gm.ProtoTable{Headers: &gm.ProtoTableRow{Cells: []string{"a"}}, Rows: []*gm.ProtoTableRow{{Cells: []string{"c"}}}}},207 {208 ItemType: gm.ProtoItem_TableDrivenScenario, TableDrivenScenario: &gm.ProtoTableDrivenScenario{209 Scenario: &gm.ProtoScenario{ExecutionStatus: gm.ExecutionStatus_SKIPPED, ScenarioHeading: "scenario Heading2", SkipErrors: []string{"error"}},210 TableRowIndex: 1,211 },212 },213 },214 }, ExecutionTime: int64(2),215 Skipped: true,216 },217 })218 want := &result.SpecResult{219 ProtoSpec: &gm.ProtoSpec{220 SpecHeading: "heading", FileName: "filename", Tags: []string{"tags"},221 Items: []*gm.ProtoItem{222 {ItemType: gm.ProtoItem_Table, Table: &gm.ProtoTable{Headers: &gm.ProtoTableRow{Cells: []string{"a"}}, Rows: []*gm.ProtoTableRow{{Cells: []string{"b"}}, {Cells: []string{"c"}}}}},223 {ItemType: gm.ProtoItem_Scenario, Scenario: &gm.ProtoScenario{ExecutionStatus: gm.ExecutionStatus_SKIPPED, SkipErrors: []string{"error"}, ScenarioHeading: "scenario Heading1"}},224 {225 ItemType: gm.ProtoItem_TableDrivenScenario, TableDrivenScenario: &gm.ProtoTableDrivenScenario{226 Scenario: &gm.ProtoScenario{ExecutionStatus: gm.ExecutionStatus_SKIPPED, SkipErrors: []string{"error"}, ScenarioHeading: "scenario Heading2"},227 TableRowIndex: 0,228 },229 },230 {231 ItemType: gm.ProtoItem_TableDrivenScenario, TableDrivenScenario: &gm.ProtoTableDrivenScenario{232 Scenario: &gm.ProtoScenario{ExecutionStatus: gm.ExecutionStatus_SKIPPED, SkipErrors: []string{"error"}, ScenarioHeading: "scenario Heading2"},233 TableRowIndex: 1,234 },235 },236 }, IsTableDriven: false,237 },238 ScenarioCount: 3, ScenarioSkippedCount: 3, ScenarioFailedCount: 0, IsFailed: false, Skipped: true, ExecutionTime: int64(3),239 }240 if !reflect.DeepEqual(got, want) {241 t.Errorf("Merge data table spec results failed.\n\tWant: %v\n\tGot: %v", want, got)242 }243}244func TestMergeResultsExecutionTimeInParallel(t *testing.T) {245 InParallel = true246 got := mergeResults([]*result.SpecResult{247 {248 ProtoSpec: &gm.ProtoSpec{249 SpecHeading: "heading", FileName: "filename", Tags: []string{"tags"},250 }, ExecutionTime: int64(1),251 },252 {253 ProtoSpec: &gm.ProtoSpec{254 SpecHeading: "heading", FileName: "filename", Tags: []string{"tags"},255 }, ExecutionTime: int64(2),256 },257 })258 want := int64(2)259 InParallel = false260 if !reflect.DeepEqual(got.ExecutionTime, want) {261 t.Errorf("Execution time in parallel data table spec results.\n\tWant: %v\n\tGot: %v", want, got.ExecutionTime)262 }263}264func TestMergeDataTableSpecResults(t *testing.T) {265 res := &result.SuiteResult{266 Environment: "env",267 ProjectName: "name",268 Tags: "tags",269 SpecResults: []*result.SpecResult{270 {271 ProtoSpec: &gm.ProtoSpec{272 SpecHeading: "heading", FileName: "filename", Tags: []string{"tags"},273 Items: []*gm.ProtoItem{274 {ItemType: gm.ProtoItem_Scenario, Scenario: &gm.ProtoScenario{ExecutionStatus: gm.ExecutionStatus_PASSED, ScenarioHeading: "scenario Heading1"}},275 },276 },277 },278 },279 }280 got := mergeDataTableSpecResults(res)281 want := &result.SuiteResult{282 Environment: "env",283 ProjectName: "name",284 Tags: "tags",285 SpecResults: []*result.SpecResult{286 {287 ProtoSpec: &gm.ProtoSpec{288 SpecHeading: "heading", FileName: "filename", Tags: []string{"tags"},289 Items: []*gm.ProtoItem{290 {ItemType: gm.ProtoItem_Scenario, Scenario: &gm.ProtoScenario{ExecutionStatus: gm.ExecutionStatus_PASSED, ScenarioHeading: "scenario Heading1"}},291 },292 },293 },294 },295 }296 if !reflect.DeepEqual(got, want) {297 t.Errorf("Merge data table spec results failed.\n\tWant: %v\n\tGot: %v", want, got)298 }299}300func TestGetItems(t *testing.T) {301 table := &gm.ProtoTable{Headers: &gm.ProtoTableRow{Cells: []string{"a"}}}302 res := []*result.SpecResult{{303 ProtoSpec: &gm.ProtoSpec{304 Items: []*gm.ProtoItem{305 {ItemType: gm.ProtoItem_Table},306 {ItemType: gm.ProtoItem_Scenario},307 {ItemType: gm.ProtoItem_TableDrivenScenario},308 },309 },310 }}311 scnRes := []*gm.ProtoItem{312 {ItemType: gm.ProtoItem_Scenario}, {ItemType: gm.ProtoItem_TableDrivenScenario}, {ItemType: gm.ProtoItem_Scenario},313 }314 got := getItems(table, scnRes, res)315 want := []*gm.ProtoItem{{ItemType: gm.ProtoItem_Table, Table: table}, {ItemType: gm.ProtoItem_Scenario}, {ItemType: gm.ProtoItem_TableDrivenScenario}, {ItemType: gm.ProtoItem_Scenario}}316 if !reflect.DeepEqual(got, want) {317 t.Errorf("Merge data table spec results failed.\n\tWant: %v\n\tGot: %v", want, got)318 }319}320func TestHasTableDrivenSpec(t *testing.T) {321 type testcase struct {322 results []*result.SpecResult323 want bool324 }325 cases := []testcase{326 {327 results: []*result.SpecResult{328 {329 ProtoSpec: &gm.ProtoSpec{330 IsTableDriven: false,331 },332 },333 {334 ProtoSpec: &gm.ProtoSpec{335 IsTableDriven: true,336 },337 },338 },339 want: true,340 },341 {342 results: []*result.SpecResult{343 {344 ProtoSpec: &gm.ProtoSpec{345 IsTableDriven: false,346 },347 },348 {349 ProtoSpec: &gm.ProtoSpec{350 IsTableDriven: false,351 },352 },353 },354 want: false,355 },356 }357 for _, c := range cases {358 got := hasTableDrivenSpec(c.results)359 if got != c.want {360 t.Errorf("Expected hasTableDrivenSpec to be %t, got %t", c.want, got)361 }362 }363}364func TestMergeResultWithMesages(t *testing.T) {365 got := mergeResults([]*result.SpecResult{366 {367 ProtoSpec: &gm.ProtoSpec{368 PreHookFailures: []*gm.ProtoHookFailure{{StackTrace: "stacktrace"}},369 SpecHeading: "heading", FileName: "filename", Tags: []string{"tags"},370 Items: []*gm.ProtoItem{371 {ItemType: gm.ProtoItem_Table, Table: &gm.ProtoTable{Headers: &gm.ProtoTableRow{Cells: []string{"a"}}, Rows: []*gm.ProtoTableRow{{Cells: []string{"b"}}}}},372 },373 PreHookMessages: []string{"Hello"},374 }, ExecutionTime: int64(1),375 },376 {377 ProtoSpec: &gm.ProtoSpec{378 PreHookFailures: []*gm.ProtoHookFailure{{StackTrace: "stacktrace1"}},379 SpecHeading: "heading", FileName: "filename", Tags: []string{"tags"},380 Items: []*gm.ProtoItem{381 {ItemType: gm.ProtoItem_Table, Table: &gm.ProtoTable{Headers: &gm.ProtoTableRow{Cells: []string{"a"}}, Rows: []*gm.ProtoTableRow{{Cells: []string{"d"}}}}},382 },383 }, ExecutionTime: int64(2),384 },385 {386 ProtoSpec: &gm.ProtoSpec{387 PreHookFailures: []*gm.ProtoHookFailure{{StackTrace: "stacktrace2"}},388 SpecHeading: "heading", FileName: "filename", Tags: []string{"tags"},389 Items: []*gm.ProtoItem{390 {ItemType: gm.ProtoItem_Table, Table: &gm.ProtoTable{Headers: &gm.ProtoTableRow{Cells: []string{"a"}}, Rows: []*gm.ProtoTableRow{{Cells: []string{"c"}}}}},391 },392 PostHookMessages: []string{"Bye"},393 }, ExecutionTime: int64(2),394 },395 })396 want := &result.SpecResult{397 ProtoSpec: &gm.ProtoSpec{398 PreHookFailures: []*gm.ProtoHookFailure{{StackTrace: "stacktrace"}, {StackTrace: "stacktrace1", TableRowIndex: 1}, {StackTrace: "stacktrace2", TableRowIndex: 2}},399 SpecHeading: "heading", FileName: "filename", Tags: []string{"tags"},400 Items: []*gm.ProtoItem{401 {ItemType: gm.ProtoItem_Table, Table: &gm.ProtoTable{Headers: &gm.ProtoTableRow{Cells: []string{"a"}}, Rows: []*gm.ProtoTableRow{{Cells: []string{"b"}}, {Cells: []string{"d"}}, {Cells: []string{"c"}}}}},402 },403 PreHookMessages: []string{"Hello"},404 PostHookMessages: []string{"Bye"},405 IsTableDriven: false,406 },407 ScenarioCount: 0, ScenarioSkippedCount: 0, ScenarioFailedCount: 0, IsFailed: false, Skipped: false, ExecutionTime: int64(5),408 }409 if !reflect.DeepEqual(got, want) {410 t.Errorf("Merge data table spec results failed.\n\tWant: %v\n\tGot: %v", want, got)411 }412}...

Full Screen

Full Screen

specHeading

Using AI Code Generation

copy

Full Screen

1import (2func main() {3 c := cron.New()4 c.AddFunc("@every 1s", func() { fmt.Println("Every second") })5 c.AddFunc("@every 5s", func() { fmt.Println("Every 5 seconds") })6 c.Start()7 select {}8}

Full Screen

Full Screen

specHeading

Using AI Code Generation

copy

Full Screen

1import "fmt"2func main() {3 fmt.Println("Enter three numbers")4 fmt.Scanln(&a, &b, &c)5 if a > b && a > c {6 fmt.Println("a is the largest number")7 } else if b > a && b > c {8 fmt.Println("b is the largest number")9 } else {10 fmt.Println("c is the largest number")11 }12}13import "fmt"14func main() {15 fmt.Println("Enter three numbers")16 fmt.Scanln(&a, &b, &c)17 if a > b && a > c {18 fmt.Println("a is the largest number")19 } else if b > a && b > c {20 fmt.Println("b is the largest number")21 } else {22 fmt.Println("c is the largest number")23 }24}25import "fmt"26func main() {27 fmt.Println("Enter three numbers")28 fmt.Scanln(&a, &b, &c)29 if a > b && a > c {30 fmt.Println("a is the largest number")31 } else if b > a && b > c {32 fmt.Println("b is the largest number")33 } else {34 fmt.Println("c is the largest number")35 }36}37import "fmt"38func main() {39 fmt.Println("Enter three numbers")40 fmt.Scanln(&a, &b, &c)41 if a > b && a > c {42 fmt.Println("a is the largest number")43 } else if b > a && b > c {44 fmt.Println("b is the largest number")45 } else {46 fmt.Println("c is the largest number")47 }48}49import "fmt"50func main() {51 fmt.Println("Enter three

Full Screen

Full Screen

specHeading

Using AI Code Generation

copy

Full Screen

1import "fmt"2func main() {3 fmt.Println("Hello, playground")4 execution := new(Execution)5 execution.specHeading()6}7import "fmt"8func main() {9 fmt.Println("Hello, playground")10 execution := new(Execution)11 execution.specHeading()12}13import (14func main() {15 file, err := os.Open("test.txt")16 if err != nil {17 fmt.Println(err)18 }19 scanner := bufio.NewScanner(file)20 scanner.Split(bufio.ScanWords)21 for scanner.Scan() {22 fmt.Println(scanner.Text())23 }24 file.Close()25}26import (27func main() {28 file, err := os.Open("test.txt")29 if err != nil {30 fmt.Println(err)31 }

Full Screen

Full Screen

specHeading

Using AI Code Generation

copy

Full Screen

1import (2func main() {3 cmd := exec.Command("ls", "-l")4 stdout, _ := cmd.StdoutPipe()5 cmd.Start()6 buf := make([]byte, 100)7 n, _ := stdout.Read(buf)8 fmt.Println(string(buf[0:n]))9}10import (11func main() {12 cmd := exec.Command("ls", "-l")13 stdout, _ := cmd.StdoutPipe()14 cmd.Start()15 buf := make([]byte, 100)16 n, _ := stdout.Read(buf)17 fmt.Println(string(buf[0:n]))18}19import (20func main() {21 cmd := exec.Command("ls", "-l")22 stdout, _ := cmd.StdoutPipe()23 cmd.Start()24 buf := make([]byte, 100)25 n, _ := stdout.Read(buf)26 fmt.Println(string(buf[0:n]))27}28import (29func main() {30 cmd := exec.Command("ls", "-l")31 stdout, _ := cmd.StdoutPipe()32 cmd.Start()33 buf := make([]byte, 100)34 n, _ := stdout.Read(buf)35 fmt.Println(string(buf[0:n]))36}37import (38func main() {39 cmd := exec.Command("ls", "-l")40 stdout, _ := cmd.StdoutPipe()41 cmd.Start()42 buf := make([]byte, 100)43 n, _ := stdout.Read(buf)44 fmt.Println(string(buf[0:n]))45}46import (47func main() {48 cmd := exec.Command("ls", "-l")49 stdout, _ := cmd.StdoutPipe()50 cmd.Start()51 buf := make([]byte, 100)52 n, _ := stdout.Read(buf)53 fmt.Println(string(buf[0:n]))54}

Full Screen

Full Screen

specHeading

Using AI Code Generation

copy

Full Screen

1import org.openqa.selenium.WebDriver;2import org.openqa.selenium.chrome.ChromeDriver;3import org.testng.annotations.Test;4public class Execution {5 WebDriver driver;6 public void specHeading() {7 System.setProperty("webdriver.chrome.driver", "C:\\Users\\Saurabh\\Downloads\\chromedriver_wi

Full Screen

Full Screen

specHeading

Using AI Code Generation

copy

Full Screen

1import (2func main() {3 execution.SpecHeading()4 fmt.Println("Hello, World!")5}6import (7func SpecHeading() {8 fmt.Println("Hello, World!")9}10I want to import the execution package from the main package. But I am getting the error:11 /usr/local/go/src/execution (from $GOROOT)12 /home/username/go/src/execution (from $GOPATH)13I want to import the execution package from the main package. But I am getting the error:14 /usr/local/go/src/execution (from $GOROOT)15 /home/username/go/src/execution (from $GOPATH)16I want to import the execution package from the main package. But I am getting the error:17 /usr/local/go/src/execution (from $GOROOT)18 /home/username/go/src/execution (from $GOPATH)19I want to import the execution package from the main package. But I am getting the error:20 /usr/local/go/src/execution (from $GOROOT)21 /home/username/go/src/execution (from $GOPATH)22I want to import the execution package from the main package. But I am getting the error:23 /usr/local/go/src/execution (from $GOROOT)24 /home/username/go/src/execution (from $GOPATH)25I want to import

Full Screen

Full Screen

specHeading

Using AI Code Generation

copy

Full Screen

1import (2func main() {3 exec := new(execution)4 execType := reflect.TypeOf(exec)5 specHeading := execType.MethodByName("specHeading")6 if !specHeading.IsValid() {7 fmt.Println("Method specHeading is not present")8 }9 numIn := specHeadingType.NumIn()10 if numIn != 0 {11 fmt.Println("Method specHeading does not take any argument")12 }13 numOut := specHeadingType.NumOut()14 if numOut != 1 {15 fmt.Println("Method specHeading does not return any argument")16 }17 outType := specHeadingType.Out(0)18 if outType.Kind() != reflect.String {19 fmt.Println("Method specHeading does not return string")20 }21 out := specHeading.Func.Call([]reflect.Value{reflect.ValueOf(exec)})22 if outArg.Kind() != reflect.String {23 fmt.Println("Method specHeading does no

Full Screen

Full Screen

Automation Testing Tutorials

Learn to execute automation testing from scratch with LambdaTest Learning Hub. Right from setting up the prerequisites to run your first automation test, to following best practices and diving deeper into advanced test scenarios. LambdaTest Learning Hubs compile a list of step-by-step guides to help you be proficient with different test automation frameworks i.e. Selenium, Cypress, TestNG etc.

LambdaTest Learning Hubs:

YouTube

You could also refer to video tutorials over LambdaTest YouTube channel to get step by step demonstration from industry experts.

Run Gauge automation tests on LambdaTest cloud grid

Perform automation testing on 3000+ real desktop and mobile devices online.

Most used method in

Try LambdaTest Now !!

Get 100 minutes of automation test minutes FREE!!

Next-Gen App & Browser Testing Cloud

Was this article helpful?

Helpful

NotHelpful