UNPKG

artillery

Version:

Flexible and powerful toolkit for load and functional testing

40 lines (28 loc) 1.39 kB
# Writing an Artillery engine Artillery has an engine interface. An engine can be used by artillery to execute requests using protocols that are not supported out-of-the-box. ## Writing an engine #### Naming Your engine's node package name should follow the convention of `artillery-engine-[engine name]`. #### Files Only 2 files are required: `package.json` and `index.js`. #### `index.js` The engine's `index.js` file should export a single default object. Object is expected to have a method named `createScenario`, which will be called by artillery each time scenario is executed, will receive the scenario's configuration and is expected to return a function that internally executes all logic in scenario. ##### Example for minimal `index.js` implementation: ``` function MyNewEngine(script, ee, helpers) { this.script = script; this.ee = ee; this.helpers = helpers; return this; } MyNewEngine.prototype.createScenario = function createScenario(scenarioSpec, ee) { function executeMyScenario() { ee.emit('started'); ee.emit('done'); }; return executeMyScenario; }; module.exports = MyNewEngine; ``` This is of course very minimal. The scenario spec typically includes a flow in it, and it is up to you as the developer to return a function that executes the full flow listed in the configuration, using your chosen protocol.