2014-09-16 23:47
浏览 20


I've just started to build an API & Some web app features, using Behat to test scenarios in a BDD fashion.

All is going well, I'm testing the API with a Rest Context and Web App bits with Mink.

However, I've reached a bit of a stumbling block in the automated tests...

I've created an API endpoint for a "Forgot Password" feature, which does the usual random hash/token effort, then emails a link to /reset-password/token

However, in order to automate testing of this URL using Mink I'd need to know the hash of the test user (created earlier in the test suite). Because it's random and will change every time a user requests a password reset, I'm a little stumped as to how I can test this!

图片转代码服务由CSDN问答提供 功能建议

我刚刚开始构建一个API& 一些Web应用程序功能,使用Behat以BDD方式测试场景。

一切顺利,我正在使用Mink测试具有Rest Context和Web App位的API。


我为“忘记”创建了一个API端点 密码“功能,执行通常的随机哈希/令牌工作,然后通过电子邮件发送链接到/ reset-password / 令牌

但是,为了自动化测试 这个URL使用Mink我需要知道测试用户的哈希值(在测试套件中先前创建)。 因为它是随机的,并且每次用户请求重置密码时都会改变,所以我对如何测试它感到有点难过!

  • 点赞
  • 写回答
  • 关注问题
  • 收藏
  • 邀请回答

1条回答 默认 最新

  • duancuisan2503 2014-09-17 10:06

    Simple: don't be shy to lookup the last (or based on any other criteria) row in your password reset tokens table to get the last generated hash.

    If you are new to subject it might sound a little strange that with Behat / Mink you need to do things like that, but thats a totally normal practice to have shortcuts or workarounds like that.

    点赞 评论

相关推荐 更多相似问题