We have a large multi-developer project under Rails in which we are using tests for both models and controllers. Right now the developers have to switch the DB parameters for the 'test' environment to match their local dev environments before running tests. I am wondering if there is a way to run those tests on any environment other than 'test'?
For example we have in database.yml:
test:
database: ...
host: ...
username: ...
password: ...
...
dev-one:
...
dev-two:
...
I can't find anything in the docs on this but maybe I am looking in the wrong place. Any ideas?
Thanks!
Yes of course! Unit tests run on all build configurations. Unit tests are always intact but this does not mean that shipped assemblies are dependent on anything relating to the tests. Tests are always written in a parallel assembly (in the same build environment) that then tests the production assembly.
Integration. Don't try to test all the combinations in integration tests. That's what unit tests are for. Just test happy-paths or most common cases.
2.7 The Rails Test Runner Or we can run a single test file by passing the bin/rails test command the filename containing the test cases. This will run all test methods from the test case. You can also run a particular test method from the test case by providing the -n or --name flag and the test's method name.
They make sure that a section of an application, or a “unit”, is behaving as intended. In a Rails context, unit tests are what you use to test your models. Although it is possible in Rails to run all tests simultaneously, each unit test case should be tested independently to isolate issues that may arise.
As of right now this still does not work. I've submitted an issue: https://github.com/rails/rails/issues/21478.
I'll edit this answer with updates
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With