Skip to content

Commit cb4446e

Browse files
committed
added instructions for running tests locally
1 parent 8e28d79 commit cb4446e

File tree

3 files changed

+43
-7
lines changed

3 files changed

+43
-7
lines changed

contributing/quickstart.md

+16-6
Original file line numberDiff line numberDiff line change
@@ -24,17 +24,27 @@ There are two options here - a "test" database with generated data, or the produ
2424
## (3) RUNNING TESTS
2525
Two options - running while your docker server is running, or running tests independently.
2626

27+
### **RUNNING WHILE SERVER IS LIVE**
28+
With your docker server running:
29+
1. Create `WcaOnRails/.env.test.local` with the following contents (this overrides `.env.test`, which is set up for testing in Github Actions, which uses a different db configuration):
30+
```bash
31+
DATABASE_HOST=127.0.0.1
32+
DATABASE_PASSWORD=
33+
```
34+
1. Connect to the `rails` container using `docker exec -it rails bash`
35+
2. You'll now be in the terminal shell - run `RAILS_ENV=test rspec`
36+
37+
You may want to consider the following options to make the test suite run faster:
38+
- Add `--fail-fast` to have the suit terminate after the first failure
39+
- Specify a folder/filename to limit how many tests get executed
40+
41+
A full command using these options would look like: `RAILS_ENV=test rspec spec/features/register_for_competition_spec.rb --fail-fast`
42+
2743
### **RUNNING INDEPENDENTLY**
2844
```
2945
docker-compose exec wca_on_rails bash -c "RAILS_ENV=test bin/rake db:reset && RAILS_ENV=test bin/rake assets:precompile && bin/rspec"
3046
```
3147
32-
### **RUNNING WHILE SERVER IS LIVE**
33-
With your docker server running:
34-
1. Connect to the `wca_on_rails` container using `docker exec -it {container_id} bash`
35-
1. _Use `docker ps` to list containers and their id's_
36-
2. Run `bin/rspec` from inside the container's terminal
37-
3848
----
3949
4050
[^1]: The website can also be run with `rails server` - see [Running with Rails](/guides/running_with_rails)

guides/_tdd_on_the_monolith.md

+27
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,27 @@
1+
---
2+
title: TDD on the Monolith
3+
layout: default
4+
parent: Guides
5+
---
6+
7+
* *TDD:* Test-Driven Development
8+
* *Monolith:* The main worldcubeassociation repo ("monolith" as opposed to "microservices")
9+
10+
### Why do TDD?
11+
12+
Automated tests are an essential part of being able to work on the WCA's codebase with confidence. We don't need to worry about what unforseen consequences a change we make might have, we just need to run the tests and see whether or not they pass. In an open-source system with many different contributors, this is crucial.
13+
14+
- Tests are crucial for our development workflow. They have to be written at some point, and writing them while developing is easier than writing them at the end when you just want to ship the PR already.
15+
- We tend to write more and better tests when testing during development than after it, as our code is written with testing in mind - meaning we are more likely to use patterns like loose coupling and dependency injection.
16+
17+
### Challenges of TDD in the monolith
18+
19+
In TDD, you want to run tests every few minutes when developing or refactoring, and you want quick feedback from the tests - ideally, executing in under 10 seconds. The larger suite should then be run after each significant TDD workflow.
20+
21+
Running the monolith's tests locally is far too slow, for 2 reasons:
22+
1. Size of test suite - 6000 tests take a long time to run, no way around that
23+
2. Long startup time for tests
24+
25+
Why the long startup time?
26+
- Long compilation time for RSpec tests?
27+
- Takes a long time to load testing plugins?

wst-processes/common_requests.md

-1
Original file line numberDiff line numberDiff line change
@@ -34,4 +34,3 @@ AWS will send an email with the title "Action Required - Your certificate renewa
3434
3. Click on the certificate with the relevant name in the "Domain name" column
3535
4. Click "Create records in Route 53"
3636
5. Confirm with "Create records"
37-

0 commit comments

Comments
 (0)