Cucumber-js 测试在应该通过或失败时显示为 'pending'
Cucumber-js test showing as 'pending' when they should pass or fail
我是一名新程序员。我正在尝试设置一个 cucumber.io 套件。我阅读了文档并设置了 https://github.com/cucumber/cucumber-js/blob/master/docs/nodejs_example.md 中的示例。当我 运行 提供测试时,示例测试按预期通过。
场景:阅读文档
✔ 鉴于我在 Cucumber.js GitHub 存储库
✔ 当我点击 "CLI"
✔ 那我应该看看 "Running specific features"
1 个场景(1 个通过)
3 步(3 步通过)
0m03.724s
以示例为起点,当我添加另一个 .feature 和 .js 文件并 运行 测试时,我的新测试的所有操作都显示为 'pending'。此外,第一个测试不再通过:
3 个场景(1 个模棱两可,2 个未定义)
10 个步骤(2 个不明确,7 个未定义,1 个通过)
0m03.743s
任何人都可以告诉我我需要做什么才能进行测试 运行?我需要做什么来删除模棱两可和未定义的测试?
我检查了我的正则表达式,它匹配。我知道我的缩进不在这里,但我是发布代码的新手!
我的.feature 文件:
Feature: Sign In
As a returning user of examples
I want to log in the site
So that I can use the site
Scenario: Getting to the Sign in page via "Log In"
Given I am on example.com
When I click the "Sign In" button
Then I am taken to the login screen
Scenario: Entering my information
Given I am on the login and I am the landing tab "Log In"
When I enter my credentials
And click the arrow
Then I am successfully logged in
我的测试:
var seleniumWebdriver = require('selenium-webdriver');
module.exports = function () {
this.Given(/^I am on I am on example.com$/, function() {
return this.driver.get('https://example.com');
});
this.When(/^I click on "([^"]*)"$/, function (text) {
return this.driver.findElement({linkText: text}).then(function(element) {
return element.click();
});
});
this.Then(/^I should see "([^"]*)"$/, function (text) {
var xpath = "//*[contains(text(),'" + text + "')]";
var condition = seleniumWebdriver.until.elementLocated({xpath: xpath});
return this.driver.wait(condition, 5000);
});
};
原始场景 -
Scenario:
Given I am on the Cucumber.js GitHub repository - PASSED - This is the only step that passes that is present only in the original feature file.
When I click on "CLI" - AMBIGIOUS - This step is present in original feature file as well as the new feature file you created.
Then I should see "Running specific features" - AMBIGIOUS - This step is present in original feature file as well as the new feature file you created.
新场景 -
Scenario: Getting to the Sign in page via "Log In"
Given I am on example.com - UNDEFINED - The step definition you have defined mentions 'I am on' twice instead of once.
When I click the "Sign In" button - UNDEFINED - No matching step.
Then I am taken to the login screen - UNDEFINED - No matching step.
Scenario: Entering my information
Given I am on the login and I am the landing tab "Log In" - UNDEFINED - No matching step.
When I enter my credentials - UNDEFINED - No matching step.
And click the arrow - UNDEFINED - No matching step.
Then I am successfully logged in - UNDEFINED - No matching step.
因此你得到 7 个未定义的步骤、2 个不明确的步骤和 1 个通过的步骤。所以第一个原始场景变得模棱两可,另外两个未定义。
您需要从新 test.js 中删除重复的步骤并添加新的步骤定义以匹配新的场景步骤。
我是一名新程序员。我正在尝试设置一个 cucumber.io 套件。我阅读了文档并设置了 https://github.com/cucumber/cucumber-js/blob/master/docs/nodejs_example.md 中的示例。当我 运行 提供测试时,示例测试按预期通过。
场景:阅读文档
✔ 鉴于我在 Cucumber.js GitHub 存储库
✔ 当我点击 "CLI"
✔ 那我应该看看 "Running specific features"
1 个场景(1 个通过)
3 步(3 步通过)
0m03.724s
以示例为起点,当我添加另一个 .feature 和 .js 文件并 运行 测试时,我的新测试的所有操作都显示为 'pending'。此外,第一个测试不再通过:
3 个场景(1 个模棱两可,2 个未定义)
10 个步骤(2 个不明确,7 个未定义,1 个通过)
0m03.743s
任何人都可以告诉我我需要做什么才能进行测试 运行?我需要做什么来删除模棱两可和未定义的测试?
我检查了我的正则表达式,它匹配。我知道我的缩进不在这里,但我是发布代码的新手!
我的.feature 文件:
Feature: Sign In
As a returning user of examples
I want to log in the site
So that I can use the site
Scenario: Getting to the Sign in page via "Log In"
Given I am on example.com
When I click the "Sign In" button
Then I am taken to the login screen
Scenario: Entering my information
Given I am on the login and I am the landing tab "Log In"
When I enter my credentials
And click the arrow
Then I am successfully logged in
我的测试:
var seleniumWebdriver = require('selenium-webdriver');
module.exports = function () {
this.Given(/^I am on I am on example.com$/, function() {
return this.driver.get('https://example.com');
});
this.When(/^I click on "([^"]*)"$/, function (text) {
return this.driver.findElement({linkText: text}).then(function(element) {
return element.click();
});
});
this.Then(/^I should see "([^"]*)"$/, function (text) {
var xpath = "//*[contains(text(),'" + text + "')]";
var condition = seleniumWebdriver.until.elementLocated({xpath: xpath});
return this.driver.wait(condition, 5000);
});
};
原始场景 -
Scenario:
Given I am on the Cucumber.js GitHub repository - PASSED - This is the only step that passes that is present only in the original feature file.
When I click on "CLI" - AMBIGIOUS - This step is present in original feature file as well as the new feature file you created.
Then I should see "Running specific features" - AMBIGIOUS - This step is present in original feature file as well as the new feature file you created.
新场景 -
Scenario: Getting to the Sign in page via "Log In"
Given I am on example.com - UNDEFINED - The step definition you have defined mentions 'I am on' twice instead of once.
When I click the "Sign In" button - UNDEFINED - No matching step.
Then I am taken to the login screen - UNDEFINED - No matching step.
Scenario: Entering my information
Given I am on the login and I am the landing tab "Log In" - UNDEFINED - No matching step.
When I enter my credentials - UNDEFINED - No matching step.
And click the arrow - UNDEFINED - No matching step.
Then I am successfully logged in - UNDEFINED - No matching step.
因此你得到 7 个未定义的步骤、2 个不明确的步骤和 1 个通过的步骤。所以第一个原始场景变得模棱两可,另外两个未定义。
您需要从新 test.js 中删除重复的步骤并添加新的步骤定义以匹配新的场景步骤。