首页 > 解决方案 > 如何在 Mac 上运行黄瓜教程时修复错误

问题描述

我正在尝试在 Mac 上运行黄瓜教程示例。我按照教程的说明进入该给定页面(据我理解的说明),并按照该页面上的说明创建了文件(即 files和),annotation.java如.runTest.javaoutline.featureAnnotationsrc/test/java

使用的版本:

eclipse文件被保存并且在编辑器中没有显示任何明显的错误。但是当我这样做时runTest.java-> runAs->JUnit test我收到以下错误:

Feature: annotation

  #This is how background can be used to eliminate duplicate steps
  Background:  [90m# Annotation/outline.feature:4[0m
     User navigates to Facebook Given 
     I am on Facebook login page


  #Scenario with AND
  Scenario:                         [90m# Annotation/outline.feature:9[0m
    [90mWhen [0m[90mI enter username as "[0m[90m[1mTOM[0m[90m"[0m  [90m# annotation.enterUsername(String)[0m
WARNING: An illegal reflective access operation has occurred
WARNING: Illegal reflective access by cucumber.runtime.xstream.converters.collections.TreeMapConverter (file:/Users/adietz/.m2/repository/info/cukes/cucumber-core/1.0.2/cucumber-core-1.0.2.jar) to field java.util.TreeMap.comparator
WARNING: Please consider reporting this to the maintainers of cucumber.runtime.xstream.converters.collections.TreeMapConverter
WARNING: Use --illegal-access=warn to enable warnings of further illegal reflective access operations
WARNING: All illegal access operations will be denied in a future release
[1A    [31mWhen [0m[31mI enter username as "[0m[31m[1mTOM[0m[31m"[0m  [90m# annotation.enterUsername(String)[0m
      [31mjava.lang.NullPointerException
        at Annotation.annotation.enterUsername(annotation.java:22)
        at ✽.When I enter username as "TOM"(Annotation/outline.feature:10)
      [0m
    [90mAnd [0m[90mI enter password as "[0m[90m[1mJERRY[0m[90m"[0m [90m# annotation.enterPassword(String)[0m
[1A    [36mAnd [0m[36mI enter password as "[0m[36m[1mJERRY[0m[36m"[0m [90m# annotation.enterPassword(String)[0m
    [90mThen [0m[90mLogin should fail[0m          [90m# annotation.checkFail()[0m
[1A    [36mThen [0m[36mLogin should fail[0m          [90m# annotation.checkFail()[0m

  #This is how background can be used to eliminate duplicate steps
  Background:  [90m# Annotation/outline.feature:4[0m
     User navigates to Facebook Given 
     I am on Facebook login page


  #Scenario with BUT
  Scenario:                                [90m# Annotation/outline.feature:15[0m
    [90mWhen [0m[90mI enter username as "[0m[90m[1mTOM[0m[90m"[0m         [90m# annotation.enterUsername(String)[0m
[1A    [31mWhen [0m[31mI enter username as "[0m[31m[1mTOM[0m[31m"[0m         [90m# annotation.enterUsername(String)[0m
      [31mjava.lang.NullPointerException
        at Annotation.annotation.enterUsername(annotation.java:22)
        at ✽.When I enter username as "TOM"(Annotation/outline.feature:16)
      [0m
    [90mAnd [0m[90mI enter password as "[0m[90m[1mJERRY[0m[90m"[0m        [90m# annotation.enterPassword(String)[0m
[1A    [36mAnd [0m[36mI enter password as "[0m[36m[1mJERRY[0m[36m"[0m        [90m# annotation.enterPassword(String)[0m
    [90mThen [0m[90mLogin should fail[0m                 [90m# annotation.checkFail()[0m
[1A    [36mThen [0m[36mLogin should fail[0m                 [90m# annotation.checkFail()[0m
    [90mBut [0m[90mRelogin option should be available[0m [90m# annotation.checkRelogin()[0m
[1A    [36mBut [0m[36mRelogin option should be available[0m [90m# annotation.checkRelogin()[0m

java.lang.NullPointerException
    at Annotation.annotation.enterUsername(annotation.java:22)
    at ✽.When I enter username as "TOM"(Annotation/outline.feature:10)

java.lang.NullPointerException
    at Annotation.annotation.enterUsername(annotation.java:22)
    at ✽.When I enter username as "TOM"(Annotation/outline.feature:16)

我不是专家java,当然也不是专家eclipse。那么我该如何解决这个错误呢?以及如何与该教程的创建者取得联系,以便他们更新教程(使其更清晰)?

标签: javaeclipsecucumber

解决方案


推荐阅读