Js_test_framework
This tool is mainly used for Web front-end unit testing, to achieve field testing on the interface by invoking the JS method directly in the browser
Git address:
Https://coding.net/u/mich/p/js_test_framework/git
Process
- By testlive the request required to record in the field, Testlive records all requests during the period and can be rerun
- The testlive recorded request is output to the console, output data is written to the requestdata of the custom module, and the data is registered into the requestfactory after it is defined
- Write the test.js of the custom module, register the unit test and process test of each module in Testmanager by invoking the network request in Requestfactory and writing the assertion that needs to be judged
- Run the test cases in Testmanager, view the results in the test execution, and analyze the results
File directory Structure Example
Basic: Core Modules
Testlive
Requestfactory
Testmanager
Module: External module, for example only
User
Userrequestdata
Usertest
Product
Productrequestdata
Producttest
...
Three major modules
Each module is independent and can be customized to replace individually
Testlive
前端录制现场,通过调用回调接口,记录下用户在前端界面的所有操作记录
External interface
- Startrecord start recording, name for the recording
- Stoprecord End Video
- Output outputs the result set of all recordings
- Runrecord Running Video
- Shourequest View the directory structure and details of all recordings
- Callback external callback function, the outer function can be called in the method call, call this callback
Expansion methods
- Ajaxoverride rewrite Ajax requests to add all jquery Ajax to the callback
Requestfactory
请求工厂,主要用于收集用户的所有请求记录
External interface
- Registermethod registration method, external call through this method can register method in Requestfactory
- Registerdata registration Data, this method is similar to Registermethod, except that the parameter structure is different
- GetMethod Get method {Name: Custom method name, URL: Network request address, Methodtype: Request method, run: Execute method} from method name
- Getmethod.run can call the run function directly after passing the GetMethod, perform the method execution, return the result {costtime: Overhead time, RequestData: Request parameter, type: Request method, URL: Network request address, ResponseData: The server returns the result, success: whether the request was successful}
- Showmethods Show all requests in the Requestfactory
Testmanager
测试集成,用于管理测试,将测试模块化,以及结果的展示
External interface
- Registermethod registration method, external call through this method can register method in Testmanager
- Registerdata registration Data, this method is similar to Registermethod, except that the parameter structure is different
- Run running method, return value is the result details of this run
The directory structure is {assertqueue: All assertion result set, ResponseQueue: All request result set, Errassertqueue: All assertion Failed collection, Errorresponsequeue: All network request failed collection, Spendtime: Request time overhead, success: Success}
- ShowAll Show Testing the directory structure of all modules
- Showmethods the module name to show all the test methods under the module
Internal Tool class
Assertqueue Assertion Queue This class is used to record and determine whether the user's target result is consistent with the actual result, and the output result set
- Result-related data
- Recordresponse used to record the results of a network request
- Assert user-Set assertions
A self-made simple test tool based on page JS