2010-07-12 36 views
6

我剛剛安裝了黃瓜,我測試了它。我得到以下錯誤:黃瓜錯誤被壓制(未完全顯示)

teefcomp:cucumber-intro teef$ cucumber features/manage_users.feature 
Using the default profile... 
F----F 

Failing Scenarios: 
cucumber features/manage_users.feature:6 # Scenario: User List 

1 scenario (1 failed) 
4 steps (4 skipped) 
0m0.029s 

它似乎在抑制錯誤。我期待的是這樣的:

Feature: Manage users 
    In order to understand my user base better 
    As an administrator 
    I want to view a list of users 

    Scenario: User List 
    Given I have users named George, Mary 
     uninitialized constant User (NameError) 
     ./features/step_definitions/user_steps.rb:3 
     ./features/step_definitions/user_steps.rb:2:in '/^I have users named (.*)$/' 
     features/manage_users.feature:7:in 'Given I have users named George, Mary' 

任何人都知道如何讓黃瓜顯示完整的錯誤?

--backtrace--verbose-b--trace不工作;我仍然看到F----F並列出了失敗的場景,但我仍然期望類似於「NameError」行中的描述。這是黃瓜老版本的功能嗎? (我用屏幕錄像開始使用黃瓜。)

回答

12

-b標誌運行應該給你一個完整的回溯

cucumber features/manage_users.feature -b 

編輯:

此外,還可以使用--backtrace完整符號。如果您正在通過耙運行,請使用--trace標誌運行

以獲得完整輸出,您可以使用--format標誌。我通常使用--format pretty來逐行閱讀。

--help輸出。

-f, --format FORMAT    How to format features (Default: pretty). Available formats: 
            debug  : For developing formatters - prints the calls made to the listeners. 
            html  : Generates a nice looking HTML report. 
            json  : Prints the feature as JSON 
            json_pretty : Prints the feature as pretty JSON 
            junit  : Generates a report similar to Ant+JUnit. 
            pdf   : Generates a PDF report. You need to have the 
               prawn gem installed. Will pick up logo from 
               features/support/logo.png or 
               features/support/logo.jpg if present. 
            pretty  : Prints the feature as is - in colours. 
            progress : Prints one character per scenario. 
            rerun  : Prints failing files with line numbers. 
            stepdefs : Prints All step definitions with their locations. Same as 
               the usage formatter, except that steps are not printed. 
            tag_cloud : Prints a tag cloud of tag usage. 
            usage  : Prints where step definitions are used. 
               The slowest step definitions (with duration) are 
               listed first. If --dry-run is used the duration 
               is not shown, and step definitions are sorted by 
               filename instead. 
           Use --format rerun --out features.txt to write out failing 
           features. You can rerun them with cucumber @rerun.txt. 
           FORMAT can also be the fully qualified class name of 
           your own custom formatter. If the class isn't loaded, 
           Cucumber will attempt to require a file with a relative 
           file name that is the underscore name of the class name. 
           Example: --format Foo::BarZap -> Cucumber will look for 
           foo/bar_zap.rb. You can place the file with this relative 
           path underneath your features/support directory or anywhere 
           on Ruby's LOAD_PATH, for example in a Ruby gem. 
+0

嗯,那仍然沒有給我完整的BT。我得到了相同的輸出... – user5243421 2010-07-12 22:54:27

+0

嘗試'--backtrace'和'--verbose' – 2010-07-12 22:55:18

+0

兩者都給我額外的信息,但是最有用的信息(「未初始化的常量User(NameError)」行)仍然顯示。 – user5243421 2010-07-12 23:01:00

0

如果您的應用程序是一個Rails應用程序,你可以使用@允許救援標記爲方案的興趣,那麼你的軌道test_log將包括大約凡在你的應用程序中的錯誤最初提出更多細節。

從命令行中,您可以使用tail -n200 log/test_log.rb快速查看測試日誌的結尾(調整行數以查看感興趣的部分)。