mirror of
https://github.com/httprunner/httprunner.git
synced 2026-07-20 12:02:10 +08:00
feat: support pre hook and post hook for actions
This commit is contained in:
@@ -8,6 +8,7 @@ import (
|
||||
"testing"
|
||||
"time"
|
||||
|
||||
"github.com/rs/zerolog/log"
|
||||
"github.com/stretchr/testify/assert"
|
||||
"github.com/stretchr/testify/require"
|
||||
|
||||
@@ -133,6 +134,33 @@ func TestDriver_ADB_TapXY(t *testing.T) {
|
||||
assert.Nil(t, err)
|
||||
}
|
||||
|
||||
func TestDriver_ADB_TapXY_WithHook(t *testing.T) {
|
||||
driver := setupADBDriverExt(t)
|
||||
x, y := 0.4, 0.5
|
||||
err := driver.TapXY(x, y,
|
||||
option.WithHooks(
|
||||
func() {
|
||||
log.Info().Msg("pre hook")
|
||||
x += 1
|
||||
},
|
||||
func() {
|
||||
log.Info().Msg("post hook")
|
||||
},
|
||||
),
|
||||
)
|
||||
assert.Nil(t, err)
|
||||
|
||||
err = driver.TapXY(0.4, 0.5,
|
||||
option.WithPreHook(func() {
|
||||
log.Info().Msg("pre hook")
|
||||
}),
|
||||
option.WithPostHook(func() {
|
||||
log.Info().Msg("post hook")
|
||||
}),
|
||||
)
|
||||
assert.Nil(t, err)
|
||||
}
|
||||
|
||||
func TestDriver_ADB_TapAbsXY(t *testing.T) {
|
||||
driver := setupADBDriverExt(t)
|
||||
err := driver.TapAbsXY(100, 300)
|
||||
|
||||
Reference in New Issue
Block a user