io.cucumber.core.gherkin.FeatureParserException:在 1 个功能文件中运行 2 个场景时显示

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

Feature:Onboard User
    Scenario:Test whether Onboarding is successful
        Given User is on apploaded page
        When user clicks nextbutton link,navigates to upcoming onboard pages
        And Once all the onboard screens get over,loads the login page
        Then User successfully completes onboard screens

Feature: SignUp User
    Background: User is on Login page
    Scenario Outline: Test whether SignUp is successful
        Given Signup link Visibility
        When User clicks Signup link which navigates to SignUp page
        And Update <firstname>,<lastname>,<email>,<password>,<confirm password>,<phone number>and submit
        Then User successfully completes Signup and navigtes to SignIn page
        Examples:
            | firstname | lastname | email                      | password  | confirm password |
            | dona      | feble    | [email protected]        | 123456    | 123456           |
            | riya      | mary     | [email protected] | test@riya | test@riya        |

这是我的功能文件。 我得到了如下错误-

[ERROR] initializationError(Runner.AppTest)  Time elapsed: 0.004 s  <<< ERROR!
io.cucumber.core.gherkin.FeatureParserException:
Failed to parse resource at: file:///e:/LMS-cucumber-appium/src/test/resources/features/home.feature
(8:1): expected: #EOF, #TableRow, #DocStringSeparator, #StepLine, #TagLine, #ExamplesLine, #ScenarioLine, #RuleLine, #Comment, #Empty, got 'Feature: SignUp User'
(9:5): expected: #EOF, #TableRow, #DocStringSeparator, #StepLine, #TagLine, #ExamplesLine, #ScenarioLine, #RuleLine, #Comment, #Empty, got 'Background: User is on Login page'.

但是当我在单独的功能文件中运行场景时,我没有任何错误。 谁能帮我找出背后的原因吗?

cucumber gherkin cucumber-java
1个回答
0
投票

将此链接添加为书签以供将来参考:https://cucumber.io/docs/gherkin/reference/

来自文档:

Gherkin 文档中的第一个主关键字必须始终是 Feature,后跟“:”和描述该功能的简短文本。

还有:

.feature 文件中只能有一个 Feature

作为议员Korktanje 在评论中指出,您在单个

Feature
文件中包含两个
.feature
块违反了这些规则。

要解决此问题,请将功能转换为场景并将功能添加到顶部,或者保留第一个功能块,然后将第二个功能块转换为场景。按照链接的说明正确格式化您的场景以避免将来出现问题。

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