For ete, API, pressure test, due to the complexity of the project is different, different processes, although we as far as possible the exhaustion of all the test scenario, but still unable to better support for special test process, if for some special test scenarios do compatible processing, then we will demand into the indefinite development iterations, We will not be able to spare time to develop other functions for the automated test, and eventually we will be overwhelmed by these special requirements, and eventually the project will become too bloated, and the maintenance cost will rise, and the number of bugs will rise sharply.
In order to solve the fundamental problem thoroughly, we did a lot of technical scheme research, referring to the excellent open source project design scheme on the market. Finally, we referred to the plugin function of Webpack and managed the plug-in through Tapable, which greatly improved the use scenario of automatic test tools and gave users more imagination space.
Train of thought
For ETE, API and stress test, each test execution stage will expose the life cycle. Developers only need to understand the parameters exposed and received in each life cycle and customize their own plug-ins in the plug-in extension editor as required.
Then through advanced configuration mounted to the specified life cycle, before running the project open open plug-in configuration, at the time of running the project, will be priority to initialize the plug-in configuration, the plug-in mounted to the corresponding life cycle, when the execution to the current life cycle, the internal will open up a sandbox plug-in, prevent plug-in error to crash the program; In this way, the control of testing scenarios can be realized, which greatly improves the flexibility and practicability of testing tools.
Example (ETE)
ETE plug-in execution flowchart
Lifecycle hook
- Before initialization parameter (initBefore) : customize whether to execute, customize API, modify configuration parameters (set headless mode, performance analysis, behavior snapshot, enable debugging, high configuration, plug-in, timeout).
- After initialization parameters (initAfter) : customize whether to execute, customize API, modify configuration parameters (set headless mode, performance analysis, behavior snapshot, enable debugging, high configuration, plug-in, timeout).
- StepBefore: single definition filter execution use case (meets criteria), single modification parameter (looks in file), linked database assertion, single custom assertion, custom API.
- StepAfter: Single modify assertion, single replace assertion, linked database assertion, custom API.
- ResultBefore: Modify test reports in batches, modify push information in batches, define push rules, and customize push API
- Report & Push Message After (resultAfter) : Custom API
Add-in template
function myselfPlugin(config, callBack) {
const itemInfor = {
config: config.config,
params: config.item,
sendNotice: false.report: ' '.isEllipsis: false.isReplace: false
};
callBack(null, itemInfor);
}
Copy the code
parameter
config
parameter | instructions | type | The default value | Useful life |
---|---|---|---|---|
config | Project configuration information and project information | object | – | ALL |
params | Single execution parameter information | object | – | StepBefore, stepAfter |
content | The content of the HTML page for each use case test executed | string | – | StepBefore, stepAfter |
report | Test Report Results | Array | – | StepBefore, stepAfter, resultBefore, resultAfter |
lifeCycle | Cycle name | string | – | ALL |
sendNotice | Whether a message occurs after execution | boolean | – | ResultBefore, resultAfter |
callBack(param1,param2) tapable
Exposed periodic functions
param1
parameter | instructions | type | The default value | Useful life |
---|---|---|---|---|
param1 | If the argument is not null, an execution error is returned and the test is stopped | null string | – | ALL |
Param2 (Return value from plug-in modification)
parameter | instructions | type | The default value | Useful life |
---|---|---|---|---|
config | Project configuration information and project information | object | – | InitBefore, initAfter |
params | Single execution parameter | object | – | StepBefore, stepAfter |
report | Test Report Results | Array | – | StepBefore, stepAfter, resultBefore |
sendNotice | Whether a message occurs after execution | boolean | – | resultBefore |
isEllipsis | Whether to omit the test case | boolean | false | stepBefore |
isReplace | Whether to replace the test report | boolean | false | StepBefore, stepAfter |
At the end
The introduction of plug-in function greatly improves the flexibility and practicability of testing tools; Also for us to save time to polish eTest test tools, and do the development of vertical functions, continue to improve the professionalism of eTest test tools, improve the use experience of eTest test tools, please continue to pay attention to 🙏🙏🙏🙏!!