简体   繁体   中英

Cucumber only showing Capybara errors when there's an error in a Controller

I keep having an annoying issue with Cucumber. If there are any errors in the Controller, it only shows the errors raised by capybara. I'm sure that's not the way it used to work?

For example, if an exception was raised, the only output I see is: expected to find css "h1" with text "blah "

In order to actually see the error, I have to puts page.body in order to see the Controller error

Is this expected behaviour?

It is the expected behavior. Capybara is acting in the role of the user and responding to what it sees back from the server. Yes, it is annoying and makes failures hard to debug.

After you find the problem using tricks like puts page.body you should improve your lower-level test coverage to detect the cause of the error, giving a more informative failure, and then fix the problem. The better your lower-level test coverage is, the less often you'll have an error in Ruby code when running a full-stack test.

By the way, I would characterize this as an issue with full-stack testing (eg Capybara) and not a Cucumber-related issue. Cucumber can run tests that are not full-stack, and you can run full-stack tests outside of Cucumber (eg by using Capybara in RSpec)

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM