@@ -423,12 +423,12 @@ func (tc *godogFeaturesScenario) iAmListeningToSuiteEvents() error {
423
423
scenarioContext .Before (func (ctx context.Context , pickle * Scenario ) (context.Context , error ) {
424
424
tc .events = append (tc .events , & firedEvent {"BeforeScenario" , []interface {}{pickle }})
425
425
426
- return context .WithValue (ctx , ctxKey ("BeforeScenario" ), true ), nil
426
+ return context .WithValue (ctx , ctxKey ("BeforeScenario" ), pickle . Name ), nil
427
427
})
428
428
429
429
scenarioContext .Before (func (ctx context.Context , sc * Scenario ) (context.Context , error ) {
430
430
if sc .Name == "failing before and after scenario" || sc .Name == "failing before scenario" {
431
- return context .WithValue (ctx , ctxKey ("AfterStep" ), true ), errors .New ("failed in before scenario hook" )
431
+ return context .WithValue (ctx , ctxKey ("AfterStep" ), sc . Name ), errors .New ("failed in before scenario hook" )
432
432
}
433
433
434
434
return ctx , nil
@@ -453,7 +453,7 @@ func (tc *godogFeaturesScenario) iAmListeningToSuiteEvents() error {
453
453
return ctx , errors .New ("missing AfterStep in context" )
454
454
}
455
455
456
- return context .WithValue (ctx , ctxKey ("AfterScenario" ), true ), nil
456
+ return context .WithValue (ctx , ctxKey ("AfterScenario" ), pickle . Name ), nil
457
457
})
458
458
459
459
scenarioContext .StepContext ().Before (func (ctx context.Context , step * Step ) (context.Context , error ) {
@@ -463,7 +463,7 @@ func (tc *godogFeaturesScenario) iAmListeningToSuiteEvents() error {
463
463
return ctx , errors .New ("missing BeforeScenario in context" )
464
464
}
465
465
466
- return context .WithValue (ctx , ctxKey ("BeforeStep" ), true ), nil
466
+ return context .WithValue (ctx , ctxKey ("BeforeStep" ), step . Text ), nil
467
467
})
468
468
469
469
scenarioContext .StepContext ().After (func (ctx context.Context , step * Step , status StepResultStatus , err error ) (context.Context , error ) {
@@ -473,6 +473,10 @@ func (tc *godogFeaturesScenario) iAmListeningToSuiteEvents() error {
473
473
return ctx , errors .New ("missing BeforeScenario in context" )
474
474
}
475
475
476
+ if ctx .Value (ctxKey ("AfterScenario" )) != nil && status != models .Skipped {
477
+ panic ("unexpected premature AfterScenario during AfterStep: " + ctx .Value (ctxKey ("AfterScenario" )).(string ))
478
+ }
479
+
476
480
if ctx .Value (ctxKey ("BeforeStep" )) == nil {
477
481
return ctx , errors .New ("missing BeforeStep in context" )
478
482
}
@@ -485,7 +489,7 @@ func (tc *godogFeaturesScenario) iAmListeningToSuiteEvents() error {
485
489
return ctx , errors .New ("missing Step in context" )
486
490
}
487
491
488
- return context .WithValue (ctx , ctxKey ("AfterStep" ), true ), nil
492
+ return context .WithValue (ctx , ctxKey ("AfterStep" ), step . Text ), nil
489
493
})
490
494
491
495
return nil
@@ -699,10 +703,7 @@ func (tc *godogFeaturesScenario) theRenderOutputWillBe(docstring *DocString) err
699
703
actualTrimmed := actual
700
704
actual = trimAllLines (actual )
701
705
702
- expectedRows := strings .Split (expected , "\n " )
703
- actualRows := strings .Split (actual , "\n " )
704
-
705
- return assertExpectedAndActual (assert .ElementsMatch , expectedRows , actualRows , actualTrimmed )
706
+ return assertExpectedAndActual (assert .Equal , expected , actual , actualTrimmed )
706
707
}
707
708
708
709
func (tc * godogFeaturesScenario ) theRenderXMLWillBe (docstring * DocString ) error {
0 commit comments