When to choose system test over integration test Rails 5.1?

后端 未结 2 1887
借酒劲吻你
借酒劲吻你 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:50

    TL;DR: I would go with system tests instead of integration tests in any app I started today. The only advantage of integration tests is speed.

    I think system tests have 2 great advantages over integration tests:

    • They test interactions with real screens, instead of making synthetic requests for simulating those.
    • They are much more realistic and comprehensive. For example, a broken piece of Javascript will make the spec fail, while it will be ignored in an integration test.

    I think the only benefit of integration tests is speed. They are much faster indeed (check this experiment I made). For me, the speed difference is not such a big concern because:

    • I can run isolated system tests in under 2s in my box. That is fast-enough feedback for my coding happiness.
    • I rely on cloud test runners with parallelization for large suites.

    I think both local and cloud speed and parallelization are good enough today, and will only get better with time. So I believe system tests is a much safer bet if you are starting a new app today.

提交回复
热议问题