@@ -66,6 +66,54 @@ Used to test integration with [NATs](https://github.com/cloudfoundry/nats-releas
6666Previously used to both generate the v2 API docs and test the user facing JSON response for the v2 API. Instead, write a request spec.
6767To view the docs locally, cd into the ` docs/v2 ` folder, run ` python -mSimpleHTTPServer ` , and navigate to ` http://localhost:8000 ` .
6868
69+ ## Speeding Up Tests
70+
71+ ### Skip Database Recreate
72+
73+ By default, running specs with ` spec_helper ` will automatically:
74+ 1 . Drop all database tables and views
75+ 2 . Run all migrations
76+ 3 . Confirm that all migrations have run
77+
78+ See ` spec_bootstrap.rb ` for details.
79+
80+ This is an expensive operation and can increase the test load time
81+ significantly. Furthermore, it is typically not needed, since the database
82+ schema changes infrequently and there is other tooling in place to isolate data
83+ between tests (see ` database_isolation.rb ` ).
84+
85+ To skip this step, set the ` NO_DB_MIGRATION ` environment variable. You will
86+ need to unset the variable, if you modify the database schema (i.e. adding a
87+ new migration).
88+
89+ Example performance improvement:
90+
91+ ``` sh
92+ ❯ multitime -n 10 bundle exec rspec spec/unit/actions/app_create_spec.rb
93+
94+ ...
95+
96+ ===> multitime results
97+ 1: bundle exec rspec spec/unit/actions/app_create_spec.rb
98+ Mean Std.Dev. Min Median Max
99+ real 23.121 2.199 20.605 22.416 28.194
100+ user 4.100 0.105 3.902 4.103 4.292
101+ sys 2.382 0.084 2.266 2.381 2.557
102+ ```
103+
104+ ``` sh
105+ ❯ NO_DB_MIGRATION=1 multitime -n 10 bundle exec rspec spec/unit/actions/app_create_spec.rb
106+
107+ ...
108+
109+ ===> multitime results
110+ 1: bundle exec rspec spec/unit/actions/app_create_spec.rb
111+ Mean Std.Dev. Min Median Max
112+ real 9.659 0.202 9.408 9.601 9.997
113+ user 2.968 0.046 2.856 2.991 3.015
114+ sys 1.636 0.042 1.569 1.640 1.720
115+ ```
116+
69117## Running Tests In Preloaded (Fast) Mode:
70118
71119Running unit tests is a good thing, but it can be annoying waiting for
0 commit comments