Merge pull request #124 from screepers/int-test-cleanup
Integration testing cleanup
This commit is contained in:
@@ -9,8 +9,6 @@ You will need:
|
|||||||
- [Node.JS](https://nodejs.org/en/download) (>= 8.0.0)
|
- [Node.JS](https://nodejs.org/en/download) (>= 8.0.0)
|
||||||
- A Package Manager ([Yarn](https://yarnpkg.com/en/docs/getting-started) or [npm](https://docs.npmjs.com/getting-started/installing-node))
|
- A Package Manager ([Yarn](https://yarnpkg.com/en/docs/getting-started) or [npm](https://docs.npmjs.com/getting-started/installing-node))
|
||||||
- Rollup CLI (Optional, install via `npm install -g rollup`)
|
- Rollup CLI (Optional, install via `npm install -g rollup`)
|
||||||
- Build tools (`apt install build-essential` for Ubuntu, [Visual Studio](https://www.visualstudio.com/vs/) for Windows, etc)
|
|
||||||
|
|
||||||
|
|
||||||
Download the latest source [here](https://github.com/screepers/screeps-typescript-starter/archive/master.zip) and extract it to a folder.
|
Download the latest source [here](https://github.com/screepers/screeps-typescript-starter/archive/master.zip) and extract it to a folder.
|
||||||
|
|
||||||
|
|||||||
@@ -42,13 +42,40 @@ magnitude, it is recommended to prefer unit tests wherever possible.
|
|||||||
|
|
||||||
## Integration Testing
|
## Integration Testing
|
||||||
|
|
||||||
|
### Installing Screeps Server Mockup
|
||||||
|
|
||||||
|
Before starting to use integration testing, you must install [screeps-server-mockup](https://github.com/screepers/screeps-server-mockup) to your project.
|
||||||
|
Please view that repository for more instruction on installation.
|
||||||
|
|
||||||
|
```bash
|
||||||
|
# Using yarn:
|
||||||
|
yarn add -D screeps-server-mockup
|
||||||
|
# Using npm
|
||||||
|
npm install --save-dev screeps-server-mockup
|
||||||
|
```
|
||||||
|
|
||||||
|
You will also need to add scripts to run integration tests.
|
||||||
|
|
||||||
|
In `package.json`, add a new `test-integration` script and add the new integration testing to the main `test` script.
|
||||||
|
|
||||||
|
```json
|
||||||
|
"scripts": {
|
||||||
|
"test": "npm run test-unit && npm run test-integration",
|
||||||
|
"test-integration": "npm run build && rollup -c rollup.test-integration-config.js && mocha dist/test-integration.bundle.js",
|
||||||
|
}
|
||||||
|
```
|
||||||
|
|
||||||
|
Now you can run integration tests by using the `test-integration` script or run both unit and integration tests using the `test` script.
|
||||||
|
|
||||||
|
### Integration Testing with Screeps Server Mockup
|
||||||
|
|
||||||
Integration testing is for code that depends heavily on having a full game
|
Integration testing is for code that depends heavily on having a full game
|
||||||
environment. Integration tests are completely representative of the real game
|
environment. Integration tests are completely representative of the real game
|
||||||
(in fact they run with an actual Screeps server). This comes at the cost of
|
(in fact they run with an actual Screeps server). This comes at the cost of
|
||||||
performance and very involved setup when creating specific scenarios.
|
performance and very involved setup when creating specific scenarios.
|
||||||
|
|
||||||
Server testing support is implmented via
|
Server testing support is implemented via
|
||||||
[screeps-server-mockup](https://github.com/Hiryus/screeps-server-mockup). View
|
[screeps-server-mockup](https://github.com/screepers/screeps-server-mockup). View
|
||||||
this repository for more information on the API.
|
this repository for more information on the API.
|
||||||
|
|
||||||
By default the test helper will create a "stub" world with a 3x3 grid of rooms
|
By default the test helper will create a "stub" world with a 3x3 grid of rooms
|
||||||
|
|||||||
@@ -10,9 +10,9 @@
|
|||||||
"push-main": "rollup -c --environment DEST:main",
|
"push-main": "rollup -c --environment DEST:main",
|
||||||
"push-pserver": "rollup -c --environment DEST:pserver",
|
"push-pserver": "rollup -c --environment DEST:pserver",
|
||||||
"push-sim": "rollup -c --environment DEST:sim",
|
"push-sim": "rollup -c --environment DEST:sim",
|
||||||
"test": "npm run test-unit && npm run test-integration",
|
"test": "npm run test-unit",
|
||||||
"test-unit": "rollup -c rollup.test-unit-config.js && mocha dist/test-unit.bundle.js",
|
"test-unit": "rollup -c rollup.test-unit-config.js && mocha dist/test-unit.bundle.js",
|
||||||
"test-integration": "npm run build && rollup -c rollup.test-integration-config.js && mocha dist/test-integration.bundle.js",
|
"test-integration": "echo 'See docs/in-depth/testing.md for instructions on enabling integration tests'",
|
||||||
"watch-main": "rollup -cw --environment DEST:main",
|
"watch-main": "rollup -cw --environment DEST:main",
|
||||||
"watch-pserver": "rollup -cw --environment DEST:pserver",
|
"watch-pserver": "rollup -cw --environment DEST:pserver",
|
||||||
"watch-sim": "rollup -cw --environment DEST:sim"
|
"watch-sim": "rollup -cw --environment DEST:sim"
|
||||||
|
|||||||
Reference in New Issue
Block a user