2010-07-12 12 views
6

Ho appena installato cetriolo e l'ho testato. Ho ricevuto il seguente errore:Errore di cetriolo soppresso (non visualizzato completamente)

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 

Sembra stia sopprimendo l'errore. Mi aspettavo qualcosa di simile:

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' 

Qualcuno sa come ottenere il cetriolo per visualizzare gli errori in pieno?

--backtrace, --verbose, -b e --trace non funzionano; Vedo ancora F----F e lo scenario in errore è elencato, ma mi aspetto ancora qualcosa come la descrizione sulla riga "NameError". È una caratteristica di una versione più vecchia di cetriolo? (Sto usando screencast per iniziare a utilizzare il cetriolo.)

risposta

12

corsa con la bandiera -b dovrebbe darvi un backtrace completo

cucumber features/manage_users.feature -b 

EDIT:

Inoltre, è possibile utilizzare la notazione di --backtrace . Se stai utilizzando rake, corri con la bandiera --trace

per ottenere l'output completo, è possibile utilizzare il flag --format. Generalmente uso --format pretty per ottenere un passaggio riga per riga.

dall'uscita --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

Hmm, non mi sta ancora dando il pieno. Ho ottenuto la stessa uscita ... – user5243421

+0

try '--backtrace' e' --verbose' –

+0

Entrambi mi forniscono informazioni extra, tuttavia le informazioni più utili (la linea "User costante (NameError)" non inizializzata) vengono ancora visualizzate. – user5243421

0

Se l'applicazione è un'applicazione Rails, è possibile utilizzare la @ allow-salvataggio tag per lo scenario di interessi, allora il vostro rotaie test_log includerà ulteriori dettagli su dove nell'applicazione l'errore è stato originariamente sollevata .

Dalla riga di comando è possibile visualizzare rapidamente la fine del log di test con tail -n200 log/test_log.rb (regolare il numero di righe per visualizzare la porzione di interesse).