SOFAStack
Scalable Open Financial Architecture Stack (Scalable Open Financial Architecture Stack) is a finance-level distributed Architecture independently developed by Ant Financial, which contains the components needed to build a finance-level cloud native Architecture and is the best practice developed in the Financial scene.
Ant Financial developed a model-driven automated interface testing framework, SOFAACTS, within the SOFAStack system.
Making the address: https://github.com/alipay/sofa-acts.
background
With the outbreak of business requirements, ant Financial’s financial-level distributed architecture quality testing activities become complicated, which is reflected in the complex business scenarios such as distributed transaction processing process scenarios, concurrency, account state diversity, idempotency and compatibility, etc. Under the original automated testing framework, the test process orchestration is prone to the problems of scattered test data redundancy, poor maintainability, high manual coding cost and easy omission of test verification points.
How to solve the above problem?
Ant Financial developed a model-driven automated interface testing framework, SOFAACTS, within the SOFAStack system.
SOFAACTS introduction
SOFAACTS consists of an IDE and a test engine. The product architecture is shown below:
The framework ADAPTS to the test context of TestNg+Spring, takes YAML as the data carrier and builds data model driven on it. It has excellent characteristics in line with the characteristics of fast Internet development and complex distributed financial system:
- Model-driven and standard execution engines;
- Automatic write back of fine checksum data;
- Flexible scalability;
- Visual maintenance of use cases.
1. Model driven and standardized
In the exploration of separating test case data from test code, many test frameworks adopt a data-driven approach, but this cannot cope with complex financial business scenarios. Framework on the depth of case data abstraction, put forward the concept of model driven, developed based on the model of the data driven and standardized execution engine, and realized the separation of data and code management, at the same time to test in the process of data cleaning, data preparation, standardize case execution, the calibration phase, test data maintenance and test the code concise and elegant. When the use case is executed, the user does not need to focus on how the data is loaded or how the result compares to the expected data, but only on the test data and execution results.
Next, we show you how to use SOFAACTS to efficiently generate one-click data models and one-click test scripts.
Data model generation
Prepare the data model first to facilitate the rapid creation of objects and tables in a template. Prepare the DB data, interface request parameters, and return result object model as follows.
DB data model generation
1. Right-click any test code -> SOFAACTS function -> generate DB table structure template;
2. Select the generated target test project;
3. Click OK to select and add the table to generate the model.
Class object model generation
1. Right-click any method of the class definition of the model to be built -> SOFAACTS function -> Template Generation to generate the current object model;
2. After the generation, we can find the generated data object model in the following figure;
3. Follow the steps above, so we have generated the interface object template.
Now let’s start script one-click generation:
Test script generation
SOFAACTS IDE provides automatic generation of test scripts without manual coding. The operation mode is as follows:
1. Click on the interface method under test and choose SOFAACTS > Generate test cases;
2. A text box will pop up, filling in the position and encoding format of the script generation, as follows:
3. After filling in, click OK to automatically generate the following test script. It can be seen that the model-driven script is concise and elegant.
The original data-driven script is as shown in the figure below. The test data is redundant and scattered, and the manual coding cost is high and the maintainability is poor.
The practice proves that the test code construction efficiency of SOFAACTS test cases is improved by 80%, and the test data is reduced to 1/case.
2. Fine verification
To solve complex business scenarios test validation problems such as difficult, easy omission, SOFAACTS based on the concept of code tracking and analysis, through reflection mechanism and analytical result data can be automatically log collection, as the calibration data of baseline scenario cases, and continuous integration baseline full quantity factor matching to achieve fine validation. The diagram below:
At the same time, in order to improve the efficiency of data backfilling after automatic collection, the framework supports automatic writing ability of precheck data, which further realizes automatic fine check of data. The baseline verification data can be collected with one click. In ant internal practice, ACTS can improve the verification efficiency by at least 80%, while scene verification 0 is omitted.
3. Flexible and extensible
In order to cope with various special business test situations without too much change, the framework is designed to apply the principle of high cohesion and low coupling, supporting the ability to reuse the underlying code of the framework and expand according to the business personalized situation. The framework provides a rich API, test execution process of each method, each class in order to test execution process each stage (below) to be able to in the test script was for other methods or is replaced by the subclass of other polymorphism, which makes framework becomes more common, gives the framework of lightweight sex and increased flexibility.
The custom API is as follows:
For details about how to use the API, learn the product manual.
4. Use case visual maintenance
The framework supports one-stop editing of the R&D integration environment, efficient use case scripting and data maintenance, and effectively reduces repetitive data preparation code. The diagram below:
conclusion
That is a basic introduction to the SOFAACTS testing framework, as well as the many capabilities you can check out in our detailed user manual.
At present, SOFAACTS has been widely used in Ant Financial, and the performance of minuter-level use case writing has been improved by 10 times. The total number of use cases is more than 10W, and the use of high-frequency functions can reach nearly 2,000 times per day, and it continues to maintain strong vitality.
At present, the code has been open source hosted on GitHub, welcome to pay attention to, but also welcome industry enthusiasts to create better SOFAACTS.
Making project address: https://github.com/alipay/sofa-acts
A link to the
- SOFAACTS: github.com/alipay/sofa…
- API Product Manual: www.sofastack.tech/sofa-acts/d…
- SOFAACTS Detailed User manual: www.sofastack.tech/sofa-acts/d…
recruitment
Ant Financial financial core test technology team is constantly looking for partners who are passionate about test automation and intelligent risk management and control to join us. If you are interested, please contact [email protected]
Financial Class Distributed Architecture (Antfin_SOFA)