黄瓜Js,如果我需要使用给定步骤中的值,什么是最佳做法?

问题描述 投票:1回答:1

我知道的方法是这个

Given(
  `Step1`,
  async function() {
    const IwantToUseThisObj = {
      A: 'a',
      B: 'b'
    }

    this.IwantToUseThisObj = IwantToUseThisObj
  }
)

Then(`Step2`, async function() {
  IwantToUseThisObj = this.IwantToUseThisObj
})

但是我不确定这是否是最佳实践,如果我需要大量使用它,它看起来非常重复,

还有更好的方法吗?我只想使用在给定步骤中使用的值

javascript selenium-webdriver bdd cucumberjs
1个回答
0
投票

是的,将数据存储在世界一流的位置上以进行重用是黄瓜的最佳做法

© www.soinside.com 2019 - 2024. All rights reserved.