Skip to content

Commit 0ed202d

Browse files
committed
Add testing notes to contribution documentation.
1 parent 0c14d8d commit 0ed202d

File tree

1 file changed

+74
-0
lines changed

1 file changed

+74
-0
lines changed

CONTRIBUTING.md

Lines changed: 74 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -85,3 +85,77 @@ Once installed, you can check your changes with:
8585
```
8686
$ ./etc/scripts/hlint.sh
8787
```
88+
89+
## Testing
90+
91+
The Stack code has both unit tests and integration tests. Integration tests can
92+
be found in the [test/integration](https://github.com/commercialhaskell/stack/tree/master/test/integration)
93+
folder and unit tests, in the [src/test](https://github.com/commercialhaskell/stack/tree/master/src/test)
94+
folder. Tests are written using the [Hspec](https://hspec.github.io/) framework. In
95+
order to run the full test suite, you can simply do:
96+
97+
```bash
98+
$ stack test
99+
```
100+
101+
The `--file-watch` is a very useful option to get quick feedback. However,
102+
running the entire test suite after each file change will slow you down. You'll
103+
need to specify which test suite (unit test or integration) and pass arguments
104+
to specify which module you'd specifically like to run to get quick feedback. A
105+
description of this follows below.
106+
107+
### Working with Unit Tests
108+
109+
If you would like to run the unit tests on their own, you can:
110+
111+
```bash
112+
$ stack test stack:stack-test
113+
```
114+
115+
Running an individual module works like this:
116+
117+
```bash
118+
$ stack test stack:stack-test --ta "-m <PATTERN>"
119+
```
120+
121+
Where `<PATTERN>` is the name of the module without `Spec.hs`.
122+
123+
You may also load tests into GHCi and run them with:
124+
125+
```bash
126+
$ stack ghci stack:stack-test --only-main
127+
# GHCi starting up output ...
128+
> :main -m "<PATTERN>"
129+
```
130+
131+
Where again, `<PATTERN>` is the name of the module without `Spec.hs`.
132+
133+
### Working with Integration Tests
134+
135+
Running the integration tests is a little involved, you'll need to:
136+
137+
```bash
138+
$ stack test stack:integration-test --flag stack:stack-integration-tests
139+
```
140+
141+
Running an individual module works like this:
142+
143+
```bash
144+
$ stack test stack:stack-integration-test --flag stack:integration-tests --ta "-m <PATTERN>"
145+
```
146+
147+
Where `<PATTERN>` is the name of the folder listed in the
148+
[test/integration/tests/](https://github.com/commercialhaskell/stack/tree/master/test/integration/tests)
149+
folder.
150+
151+
You may also achieve this through GHCi with:
152+
153+
```bash
154+
$ stack ghci stack:stack-integration-test
155+
# GHCi starting up output ...
156+
> :main -m "<PATTERN>"
157+
```
158+
159+
Where again, `<PATTERN>` is the name of the folder listed in the
160+
[test/integration/tests/](https://github.com/commercialhaskell/stack/tree/master/test/integration/tests)
161+
folder.

0 commit comments

Comments
 (0)