You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Copy file name to clipboardExpand all lines: docs/OrganizingTestSuites.md
+46-22Lines changed: 46 additions & 22 deletions
Display the source diff
Display the rich diff
Original file line number
Diff line number
Diff line change
@@ -3,13 +3,15 @@ id: organizingsuites
3
3
title: Organizing Test Suite
4
4
---
5
5
6
-
While your project is growing you will inevitably add more and more integration tests. This will increase your build time and will also slow down your productivity. To prevent this you should start to run your tests in parallel. You might have already recognised that WebdriverIO creates for each spec (or feature file in cucumber) a single WebDriver session. In general, you should try to test a single feature in your app in one spec file. Try to not have too many or too few tests in one file. However, there is no golden rule about that.
6
+
As projects grow, inevitably more and more integration tests are added. This increases build time and slows productivity.
7
7
8
-
Once you get more and more spec files you should start running them concurrently. To do so you can adjust the `maxInstances` property in your config file. WebdriverIO allows you to run your tests with maximum concurrency meaning that no matter how many files and tests you have, they could run all in parallel. Though there are certain limits (computer CPU, concurrency restrictions).
8
+
To prevent this, you should run your tests in parallel. WebdriverIO already tests each spec (or <dfn>feature file</dfn> in Cucumber) in parallel within a single session. In general, try to test a only a single feature per spec file. Try to not have too many or too few tests in one file. (However, there is no golden rule here.)
9
9
10
-
> Let's say you have 3 different capabilities (Chrome, Firefox, and Safari) and you have set maxInstances to 1, the wdio test runner will spawn 3 processes. Therefore, if you have 10 spec files and you set maxInstances to 10; all spec files will get tested at the same time and 30 processes will get spawned.
10
+
Once your tests have several spec files, you should start running your tests concurrently. To do this, adjust the `maxInstances` property in your config file. WebdriverIO allows you to run your tests with maximum concurrency—meaning that no matter how many files and tests you have, they can run all in parallel. (Certain limits still apply, like your computer’s CPU, concurrency restrictions, etc.)
11
11
12
-
You can define the `maxInstance` property globally to set the attribute for all browser. If you run your own WebDriver grid it could be that you have more capacity for one browser than for an other one. In this case you can limit the `maxInstance` in your capability object:
12
+
> Let's say you have 3 different capabilities (Chrome, Firefox, and Safari) and you have set `maxInstances` to `1`. The wdio test runner will spawn 3 processes. Therefore, if you have 10 spec files and you set `maxInstances` to `10`, _all_ spec files will get tested simultaneously, and 30 processes will get spawned.
13
+
14
+
You can define the `maxInstances` property globally to set the attribute for all browsers. If you run your own WebDriver grid, you may (for example) have more capacity for one browser than another. In this case, you can _limit_ the `maxInstances` in your capability object:
13
15
14
16
```js
15
17
// wdio.conf.js
@@ -32,7 +34,9 @@ exports.config = {
32
34
33
35
## Inherit From Main Config File
34
36
35
-
If you run your test suite in multiple environments (e.g. dev and integration) it could be helpful to have multiple configuration files to keep them easy manageable. Similar to the [page object concept](PageObjects.md) you first create a main config file. It contains all configurations you share across environments. Then for each environment you can create a file and supplement the information from the main config file with environment specific ones:
37
+
If you run your test suite in multiple environments (e.g., dev and integration) it may help to use multiple configuration files to keep things manageable.
38
+
39
+
Similar to the [page object concept](PageObjects.md), the first thing you’ll need is a main config file. It contains all configurations you share across environments. Then create another config file for each environment, and supplement the the main config with the environment-specific ones:
You can easily group test specs in suites and run single specific suites instead of all of them.
60
66
61
-
You can easily group test specs in suites and run single specific suites instead of all of them. To do so you first need to define your suites in your wdio config:
67
+
First, define your suites in your wdio config:
62
68
63
69
```js
64
70
// wdio.conf.js
@@ -80,67 +86,81 @@ exports.config = {
80
86
}
81
87
```
82
88
83
-
Now, if you want to only run a single suite, you can pass the suite name as cli argument like:
89
+
Now, if you want to only run a single suite, you can pass the suite name as a CLI argument:
In some cases, you may wish to only execute a single test or a subset of your suites. With the `--spec` parameter you can specify which suite (Mocha, Jasmine) or feature (Cucumber) should be run. For example if you only want to run your login test, do:
103
+
In some cases, you may wish to only execute a single test (or subset of tests) of your suites.
104
+
105
+
With the `--spec` parameter, you can specify which _suite_ (Mocha, Jasmine) or _feature_ (Cucumber) should be run.
If the spec passed in is not a path to a spec file, it is used as a filter for the spec file names defined in your configuration file. To run all specs with the word 'dialog' in the spec file names, you could use:
119
+
If the `--spec` given does not point to a particular spec file, it is used as a filter for the spec filenames defined in your configuration.
120
+
121
+
To run all specs with the word 'dialog' in the spec file names, you could use:
110
122
111
123
```sh
112
124
wdio wdio.conf.js --spec dialog
113
125
```
114
126
115
-
Note that each test file is running in a single test runner process. Since we don't scan files in advance (see the next section for information on piping filenames to `wdio`) you _can't_ use for example `describe.only` at the top of your spec file to say Mocha to only run that suite. This feature will help you though to do that in the same way.
127
+
Note that each test file is running in a single test runner process. Since we don't scan files in advance (see the next section for information on piping filenames to `wdio`), you _can't_ use (for example)`describe.only` at the top of your spec file to instruct Mocha to run only that suite. This feature will help you to accomplish the same goal.
116
128
117
129
## Exclude Selected Tests
118
130
119
-
When needed, if you need to exclude particular spec file(s) from a run, you can use the `--exclude` parameter (Mocha, Jasmine) or feature (Cucumber). For example if you want to exclude your login
120
-
test from the test run, do:
121
-
```sh
131
+
When needed, if you need to exclude particular spec file(s) from a run, you can use the `--exclude` parameter (Mocha, Jasmine) or feature (Cucumber).
132
+
133
+
For example, to exclude your login test from the test run:
It is sometimes necessary—in the context of continuous integration and otherwise—to specify multiple sets of specs to be run at runtime. WebdriverIO's `wdio` command line utility will accept piped input in the form of filenames (from `find`, `grep`, or others). These filenames will override the list of glob patterns or filenames specified in the configuration file's `spec` list.
161
+
It is sometimes necessary—in the context of continuous integration and otherwise—to specify multiple sets of specs to run. WebdriverIO's `wdio` command line utility accepts piped-in filenames (from `find`, `grep`, or others).
162
+
163
+
Piped-in filenames override the list of globs or filenames specified in the configuration's `spec` list.
@@ -150,6 +170,10 @@ _**Note:** This will_ not _override the `--spec` flag for running a single spec.
150
170
151
171
## Stop testing after failure
152
172
153
-
With the `bail` option you can specify when WebdriverIO should stop the test run after test failures. This can be helpful when you have a big test suite and want to avoid long test runs when you already know that your build will break. The option expects a number that specifies after how many spec failures it should stop the whole test run. The default is `0` meaning that it always runs all tests specs it can find.
173
+
With the `bail` option, you can tell WebdriverIO to stop testing after any test fails.
174
+
175
+
This is helpful with large test suites when you already know that your build will break, but you want to avoid the lenghty wait of a full testing run.
176
+
177
+
The `bail` option expects a number, which specifies how many test failures can occur before WebDriver stop the entire testing run. The default is `0`, meaning that it always runs all tests specs it can find.
154
178
155
179
Please see [Options Page](Options.md) for additional information on the bail configuration.
0 commit comments