Tuesday 15 March 2011

ruby on rails 3 - Better logging from Capybara/RSpec? -


I have a really hard time checking the cause of the test failure I am a very experienced programmer and the general debugging I am well aware of the techniques, but I am new to Capepara and RSPEC, so I am hoping that there is such a facility which I am unaware of that can help me.

In short , I have such a test:

  expectation {clicks ('.fake_button'); Sleep 1}. To change {Click.count} .by (1)   

When a simulated button is clicked, it creates an AJAX call to the rail app, except for other things A click record for the database. I can think of dozens of things that can fail this test and only get limited success in getting information out of logs. The tests are not unsuccessful in development and it only fails in a tiny manner in the test. One of the difference in the test environment is that in our server the tests against a server in the cloud are run on our servers, so there may be a network delay with other possible issues.

It's too much to diagnose It is difficult because very little information is coming from the unsuccessful test and certainly all database information is removed from time to time about the failure of the information. I know that the clicks.count has not changed in the test and I can assume that click ('.fake_button') succeeded, but server time sync The reason I can do 'is also not to ensure that the click was done on the right button or the AJAX call was removed.

There are a few tools to help me follow the case of this test in the web server logs (for example using automatic URL parameters), what Capra has done, and about it Detailed logging web page, such as when failure occurred, with cookie values. Can I get any of these? anything like that?

CAPEBARA limits human activities. What exactly is the test code necessary to expect it to be some real user needed. I do not think you should complain about the code.

I think it is okay to increase the wait time, say 1 to 2 because of your network delay, but it should not be more than the fair value otherwise the app does not work as a relatively real user.

To debug the capepara code, I have summarized three ways:

  1. Add the "save_and_open_page" to the place you want to see results Then a saved HTML page will appear during the trial. (I forget that the "lawns" gem should be added)

  2. Set this test to be set as a JS to see this test temporarily.

      Scenario "A mock exam", JS: True # code ends here   

    By doing this, a real browser will pop up and capebara How will you show you how this code plays?

  3. Just run $ tail log / test.log to show what happened.

No comments:

Post a Comment