Talk about automation architecture in a simple way!


Interviewer: Xiaoyu, what is the automated test architecture? How do you understand the automated test architecture?
Xiaoyu thought: Dig the grass~ ~ You pit, you can write an article on this question. However, I couldn't express it like this in my heart, so
Xiaoyu said: Well, this question, I can slowly talk about it from the following points.

What is the architecture

Software architecture is a series of related abstract patterns used to guide the design of all aspects of large-scale software systems. The software architecture is a sketch of the system. The objects described by the software architecture are abstract components that directly constitute the system. The connection between the various components clearly and relatively detailed description of the communication between the components. In the implementation phase, these abstract components are refined into actual components, such as a specific class or object. In the object-oriented field, the connection between components is usually realized by interfaces.
----->>>>The official explanation is rather vague. It may not involve the big guys of the architecture. There is still some vagueness about this.
----->>>>Xiaoyu directly tell the vernacular: software architecture is The basic structure of software, the essence of the structure is to manage complexity . A combination of components and their interfaces and elements that can complete specific behaviors.
Extended about:
architectural patterns, although there are many, but is also commonly used in these types:
layered architecture
event-driven architecture
microkernel architecture (also known as plug-in architecture)
micro Services Architecture
cloud architectures
>>> on these architectures We won’t discuss the composition and thought of the model here, otherwise we will digress--!

Architecture design ideas

1. High reusability:
Use a set of frameworks to solve the basic service construction work of different product lines, and facilitate the company to integrate the automation implementation of different product lines through the reference framework.
2. Ease of maintainability
If the technology of the framework is expanded, only this set of frameworks needs to be maintained. There is no need to maintain multiple sets of frameworks according to different product lines, which saves time and costs.
3. Separation of personnel, specificity
Business personnel only pay attention to the scripting of business code, and do not need to focus on framework technical issues;
architects only focus on the implementation of framework technology and do not need to learn specific business knowledge of business lines.
4. architects considered point:
① the selected code
>> java, python, ruby, etc.
selection ② core technology
>> the Web: Selenium
>> the APP: Appium
③ coding standard
naming >> classes, methods, variables
④ Design Example Standardize the
way of code management
>> git or svn

Why use architecture

Core: Solve common problems of script recording and make automation stable

1. Separate architects, script writers, and use case executors;
>>architecture boss: proficient in code design
>> script writer: understand the code
>> use case execution boss: you don’t understand the code
2. Pass UI objects The way of assigning custom variables enhances the legibility of the script;
3. Encapsulates Webdriver API to make it more robust;
4. Encapsulate common business scenarios into business methods to facilitate the reuse of common businesses;
5. The common script is packaged separately, avoiding the script execution personnel to modify the test script code;
6. Generate a Debug level log, which makes it easier for the automated script debugger to debug the program;
>> For the log level, you can read this article, Python logging Module .
7. Generate regression-level test reports to facilitate those who do not understand scripts to view the test results;
8. Use Suite to execute multiple scripts to manage running scripts;

Design structure of class library

1. Web UI automated test structure

config configuration file:
Keep the information that often needs to be modified (for example: user name, password, environment) in the configuration file for frequent calling.

Common public methods
Provide APIs that are not related to Webdriver but related to automated testing, including:
①Read file information
②Start browser
③Get current system time, etc.

report
①Test report : report to the project manager, product manager and boss;
②Debug log : it is convenient for automated script writers to debug the code;

objectView
saves the elements in the page, and when the UI changes, you can modify the corresponding variables, and name the UI elements with poor readability according to uniform rules

Corelib
1. Encapsulate the webdriver's api to make it more robust and form the api of the automation project
2. Provide related methods for assertion
3. Automated api provides detailed output messages for easy debugging
4. Automated api provides information to write messages to the test report method


Encapsulation of businessView business methods, according to the API provided in Corelib, encapsulate common business scenarios into methods for easy reuse

data
saves the input data information as an interface between the framework and external files

2. Appium automated test structure

In fact, it is similar to the Web UI, because it is based on the Pageobject design pattern
. Just copy the framework structure I wrote before.

app: test package management
|--------|-------such as xx.apk

|------- baseView: The encapsulation of some basic classes
|--------|-------find_element()
|--------|----- ---find_elements()
|--------|--------get_window_size()

public: Encapsulation of public methods
|--------|----------common_fun.py
|--------|----------- --|--------check_cancel_Btn()
|--------|-------------|--------check_ship_Btn()
| --------|-------------|--------get_screenSize()
|--------|------ ----desired_caps.py
|--------|-------------|--------driver driver package
|------- -|-------------|--------Log configuration file package
|--------|------------ -|--------Start APP configuration parameters
|--------|----------myunit.py
|--------|--- ----------|--------Test case startup and shutdown package
|
businessView: business logic package
|--------|-------- --loginView.py
|--------|-------------|--------Login-related operations and methods
|------ --|----------registerView.py
|--------|-------------|--------Registration related Operation and method

config: store configuration file
|--------|----------caps.py
|--------|------------ -|--------capability data configuration
|--------|----------log_conf.py
|--------|---- ---------|--------Log configuration file

data: store data drive
|--------|----------account.csv
|--------|------------ -|--------User name, password
|
log: store the generated log
|--------|----------runlog.log

report: store test report
|--------|----------report.html
|
screenshots: store screenshots

test_case: module storing test classes
|--------|----------test_login.py
|--------|---------- ---|--------Login test package: LoginTest
|--------|-------------|-------- Call the method of LoginView class to write use case
|--------|----------test_register.py
|--------|--------- ----|--------Register test package: RegisterTest
|--------|-------------|------- Call the method of the RegisterView class to write use cases

test_run: execute test script
|--------|----------run.py
|--------|------------ -|--------Automated test case execution entry
|--------|-------------|--------Generate test report

If you feel that it is not intuitive, you can refer to this article written by Xiaoyu:
"Frame Structure Composition of Appium Automation Framework from 0 to 1"
Note:
Because different projects may have different encapsulated structures, they will never change. , As long as you have mastered the thoughts, it is nothing more than, such as: whether the log file is pulled out separately or belongs to the repor folder.
It's that simple. .

Pitfalls encountered using architecture

Next, Xiaoyu will briefly talk about the pits encountered in the project.
1. The page element changes, then how to update the ui variables
>> Just update the objectView
. 2. The framework has encapsulated methods, and the script writers don’t call them, what should I do?
>>This is what Xiaoyu discovered when checking the script. If you encounter this kind of problem, you must notify, remind and correct in time. This is just in case if you are not afraid of ten thousand!
3. How to determine if the script execution fails is the api problem of the architecture or the defect of the program itself?
>>This question, Xiaoyu asked job applicants, the answer is anything, let’s not talk about it, let’s just say where to verify: When there is a problem, there are only two points:
①Check the reason for the failure first, how to check , Look at the log;
②Verify this function manually;
4. The api of the current architecture cannot meet the needs of the current project, how to extend it?
>>Directly rewrite the api of the architecture or add api (see the situation that cannot be satisfied, and then add the api according to the actual situation);
>>Write a new class to inherit the Corelib in the architecture, and improve the api in this class.
Note: General The architect will fix the situation.
5. How to access when the architecture needs to add new features?
>>Write some classes to complete the required functions, and then provide a call interface for use in the architecture

The reason why big
guys are called big guys is because they stepped on the pit; don't envy those big guys, because they were also novices;

As the saying goes:
if you don't pick up the pit, how
can you become the boss ; if you don't take the blame, how can you become the boss.

I hope everyone can become the boss of the big brothers.

Guess you like

Origin blog.csdn.net/wuyoudeyuer/article/details/107375408