Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

fix: after panic in test body context switch to afterEach #89

Merged
merged 1 commit into from
May 15, 2024
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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
Loading