When to choose system test over integration test Rails 5.1?

后端 未结 2 1916
借酒劲吻你
借酒劲吻你 2021-02-05 05:24

With the release of Rails 5.1, they included system tests. Which means we can test our JavaScript too in Rails. I see Rails guide explains a sample test creating article

2条回答
  •  长发绾君心
    2021-02-05 05:35

    The short answer has been given by MikDiet. For the long answer, check out the documentation on system and integration tests.

    System tests allow for running tests in either a real browser or a headless driver for testing full user interactions with your application.

    A quick rule of thumb is that all tests interacting with Javascript need to be run as system tests. But you could also use them to test your responsive layout, since you can specify the screen size of the browser.

    Integration tests are used to test how various parts of your application interact. They are generally used to test important workflows within our application.

    Integrations tests are different because they are not run through the browser. They still allow you to interact with the HTML of the result page, but remember that it's static output you work with.

    In integration tests, you are mostly looking at the behavior of the controller actions and not so much on what the user sees and interacts with. This part of the documentation might help you understand what integration tests are all about: Functional Tests for Your Controllers.

提交回复
热议问题