How to run all tests, including system tests, at once in Rails 6?
Asked Answered
C

2

5

To run tests in Rails 5+, I'd do two separate commands:

$ rails test
# Running:
........    
$ rails test:system
# Running:
........

How can I run both sets of tests from a single command line request?

Chivy answered 5/11, 2020 at 17:44 Comment(0)
C
5

To run all tests, you can list them all:

$ rails test:system test:models test:mailers ....

And you'll get the correct summarized totals:

Finished in 15.824006s, 1.8327 runs/s, 4.2973 assertions/s.
30 runs, 69 assertions, 0 failures, 0 errors, 0 skips

The shortcut is to do:

$ rails test:system test
Finished in 14.427353s, 2.0794 runs/s, 4.7826 assertions/s.
30 runs, 69 assertions, 0 failures, 0 errors, 0 skips

Which will do all of your tests since "test" includes all tests, except 'test:system'. One caveat is that if you list 'test' first, it won't run your system tests.

So, this will only run 'test', and not 'test:system'

$ rails test test:system
Finished in 0.736070s, 13.5857 runs/s, 23.0956 assertions/s.
10 runs, 17 assertions, 0 failures, 0 errors, 0 skips
Chivy answered 5/11, 2020 at 17:44 Comment(0)
S
6

Running "$ rails --tasks" we find this new command (I'm using rails 6.1.3.2):

$ rails test:all   # Runs all tests, including system tests
Sway answered 24/9, 2021 at 13:28 Comment(0)
C
5

To run all tests, you can list them all:

$ rails test:system test:models test:mailers ....

And you'll get the correct summarized totals:

Finished in 15.824006s, 1.8327 runs/s, 4.2973 assertions/s.
30 runs, 69 assertions, 0 failures, 0 errors, 0 skips

The shortcut is to do:

$ rails test:system test
Finished in 14.427353s, 2.0794 runs/s, 4.7826 assertions/s.
30 runs, 69 assertions, 0 failures, 0 errors, 0 skips

Which will do all of your tests since "test" includes all tests, except 'test:system'. One caveat is that if you list 'test' first, it won't run your system tests.

So, this will only run 'test', and not 'test:system'

$ rails test test:system
Finished in 0.736070s, 13.5857 runs/s, 23.0956 assertions/s.
10 runs, 17 assertions, 0 failures, 0 errors, 0 skips
Chivy answered 5/11, 2020 at 17:44 Comment(0)

© 2022 - 2024 — McMap. All rights reserved.