Skip to content

Commit

Permalink
Merge pull request #89 from moeryomenko/fix-incorrect-context-on-panic
Browse files Browse the repository at this point in the history
fix: after panic in test body context switch to afterEach
  • Loading branch information
dkx86 authored May 15, 2024
2 parents 43a1b4e + aa2293a commit c7e2963
Showing 1 changed file with 7 additions and 6 deletions.
13 changes: 7 additions & 6 deletions pkg/framework/runner/runner.go
Original file line number Diff line number Diff line change
Expand Up @@ -54,7 +54,7 @@ func (r *runner) toRun(result *allure.Result) bool {

func (r *runner) filterByTestPlan() map[string]Test {
if plan := r.testPlan; plan != nil {
var tests = make(map[string]Test)
tests := make(map[string]Test)
for fullName, testData := range r.tests {
if r.testPlan.IsSelected(testData.GetMeta().GetResult().TestCaseID, testData.GetMeta().GetResult().FullName) {
tests[fullName] = testData
Expand Down Expand Up @@ -175,6 +175,12 @@ func (r *runner) RunTests() SuiteResult {
}()
testT := setupTest(t, r.t().GetProvider(), test.GetMeta())

// after each hook
defer func() {
_, _ = runHook(testT, afterEachHook)
}()

// catch panic in test body context
defer func() {
rec := recover()
if rec != nil {
Expand All @@ -184,11 +190,6 @@ func (r *runner) RunTests() SuiteResult {
}
}()

// after each hook
defer func() {
_, _ = runHook(testT, afterEachHook)
}()

// before each hook
ok, err = runHook(testT, beforeEachHook)
if err != nil {
Expand Down

0 comments on commit c7e2963

Please sign in to comment.