我在我的Meteor项目中使用meteor-cucumber meteor-cucumber,后者又使用了cucumber.js。
我希望测试导航到一个网址,但如果它无效,我预计会出错。在这种情况下,有效网址为 / articles
this.When(/^I navigate to '\/articles'$/, function () {
this.browser.url(process.env.ROOT_URL, 'articles';
});
这会产生通过测试。
Scenario: View list of articles # features/articles/read_article.feature:8
Given I am logged in # features/articles/read_article.feature:9
When I navigate to '/articles' # features/articles/read_article.feature:10
Then I should see a list of articles in tile view # features/articles/read_article.feature:11
1 scenario (1 pending)
3 steps (1 pending, 2 passed)
当我将url更改为无效的内容时(例如:'articlesxxxx',测试仍然通过。这是预期的行为吗?
如果找不到网址,我希望步骤失败。
相关: How do I have a negative scenario with Cucumber in Rails?