gitee.com/mirrors/gauge@v1.0.6/execution/result/specResult_test.go (about) 1 package result 2 3 import ( 4 "github.com/getgauge/gauge/gauge_messages" 5 gc "gopkg.in/check.v1" 6 ) 7 8 func (s *MySuite) TestAddScenarioResults(c *gc.C) { 9 specItems := []*gauge_messages.ProtoItem{} 10 protoSpec := &gauge_messages.ProtoSpec{ 11 Items: specItems, 12 } 13 specResult := SpecResult{ 14 ProtoSpec: protoSpec, 15 } 16 heading := "Scenario heading" 17 item1 := &gauge_messages.ProtoItem{ItemType: gauge_messages.ProtoItem_Step, Step: &gauge_messages.ProtoStep{StepExecutionResult: &gauge_messages.ProtoStepExecutionResult{ExecutionResult: &gauge_messages.ProtoExecutionResult{}}}} 18 item2 := &gauge_messages.ProtoItem{ItemType: gauge_messages.ProtoItem_Step, Step: &gauge_messages.ProtoStep{StepExecutionResult: &gauge_messages.ProtoStepExecutionResult{ExecutionResult: &gauge_messages.ProtoExecutionResult{}}}} 19 step3Res := &gauge_messages.ProtoStepExecutionResult{ExecutionResult: &gauge_messages.ProtoExecutionResult{RecoverableError: true, Failed: false}} 20 item3 := &gauge_messages.ProtoItem{ItemType: gauge_messages.ProtoItem_Step, Step: &gauge_messages.ProtoStep{StepExecutionResult: step3Res}} 21 items := []*gauge_messages.ProtoItem{item1, item2, item3} 22 scenarioResult := NewScenarioResult(&gauge_messages.ProtoScenario{ScenarioHeading: heading, ScenarioItems: items}) 23 results := make([]Result, 0) 24 results = append(results, scenarioResult) 25 26 specResult.AddScenarioResults(results) 27 28 c.Assert(specResult.GetFailed(), gc.Equals, false) 29 c.Assert(specResult.ScenarioCount, gc.Equals, 1) 30 c.Assert(specResult.ProtoSpec.IsTableDriven, gc.Equals, false) 31 c.Assert(specResult.ScenarioFailedCount, gc.Equals, 0) 32 33 } 34 35 func (s *MySuite) TestAddTableRelatedScenarioResult(c *gc.C) { 36 specItems := []*gauge_messages.ProtoItem{} 37 protoSpec := &gauge_messages.ProtoSpec{ 38 Items: specItems, 39 } 40 specResult := SpecResult{ 41 ProtoSpec: protoSpec, 42 } 43 heading1 := "Scenario heading 1" 44 heading2 := "Scenario heading 2" 45 item1 := &gauge_messages.ProtoItem{ItemType: gauge_messages.ProtoItem_Step, Step: &gauge_messages.ProtoStep{StepExecutionResult: &gauge_messages.ProtoStepExecutionResult{ExecutionResult: &gauge_messages.ProtoExecutionResult{}}}} 46 item2 := &gauge_messages.ProtoItem{ItemType: gauge_messages.ProtoItem_Step, Step: &gauge_messages.ProtoStep{StepExecutionResult: &gauge_messages.ProtoStepExecutionResult{ExecutionResult: &gauge_messages.ProtoExecutionResult{}}}} 47 step3Res := &gauge_messages.ProtoStepExecutionResult{ExecutionResult: &gauge_messages.ProtoExecutionResult{RecoverableError: true, Failed: false}} 48 item3 := &gauge_messages.ProtoItem{ItemType: gauge_messages.ProtoItem_Step, Step: &gauge_messages.ProtoStep{StepExecutionResult: step3Res}} 49 items := []*gauge_messages.ProtoItem{item1, item2, item3} 50 scenarioResult1 := NewScenarioResult(&gauge_messages.ProtoScenario{ScenarioHeading: heading1, ScenarioItems: items}) 51 scenarioResult2 := NewScenarioResult(&gauge_messages.ProtoScenario{ScenarioHeading: heading2, ScenarioItems: items}) 52 scenarioResultsForIndex0 := []Result{scenarioResult1, scenarioResult2} 53 scenarioResultsForIndex1 := []Result{scenarioResult1, scenarioResult2} 54 results := make([][]Result, 0) 55 results = append(results, scenarioResultsForIndex0) 56 results = append(results, scenarioResultsForIndex1) 57 58 specResult.AddTableRelatedScenarioResult(results, 1) 59 60 c.Assert(specResult.GetFailed(), gc.Equals, false) 61 c.Assert(specResult.ScenarioCount, gc.Equals, 2) 62 c.Assert(specResult.ProtoSpec.IsTableDriven, gc.Equals, true) 63 c.Assert(specResult.ScenarioFailedCount, gc.Equals, 0) 64 c.Assert(specResult.ExecutionTime, gc.Equals, int64(0)) 65 }