As a test development practitioner , Automated testing seems to be a hot topic …. Combined with some recent candidates, I talked about the front-end automation test and my understanding , Share what you're right about UI Understanding of automated testing , About .
The idea of automatic test in test hierarchy
The idea of automatic test layering advocates layering the system , A test strategy of choosing the right type of automation for different levels , At the same time, the idea of automatic test layering and test stage （ unit testing , integration testing , System test ） Relevant . The coverage of automated test depends on the rationality of the strategy design of each level of automated test , overall .
Unit- unit testing
Testing is generally performed by developers , This is what we call the self-test process of developers for their own development code .
Service- Interface automation test of service integration
Usually it means API Interface automation test , In the application of layered automatic test , Interface automation is the most common automation solution .
meanwhile , Combined with data-driven testing framework , Keyword Driven test framework can meet most test scenarios , Include coverage of functions with complex business logic （B Interface dependency A Interface return ）, Reduce the redundancy of test code at the same time . Especially in the product architecture design of front and back end separation , It can effectively cover function points , As for page display , Page element layout , The validation presented can be covered by manual testing or other tools .
UI- Page automation test
UI Layers interact with users , Users pass the UI Layer interaction uses system functions . Most testing work of testers （ Black box test ） It's also concentrated on this floor . Based on personal practical experience , Not recommended in most scenarios UI automation , Difficult to maintain efficiently , Uncontrollable input-output ratio . about UI Three suggestions for automation are as follows ：
Give priority to the underlying automation coverage , Try not to UI Automation coverage .
Give priority to automatic coverage of core functions , Reduce automation coverage of non core functions .
Focus on the scalability of automation , Maintainability design .
Necessary conditions for automatic test
first , Automation or not , Generally, the following conditions need to be met at the same time ：
Infrequent changes in software requirements ( exceed 10% The change of is frequent , meanwhile 10% Not a fixed value , According to its maintenance , Appropriate adjustment threshold for extended cost )
Project cycle long enough
Automated test cases can be reused
meanwhile , Is automated testing easy to scale , Ease of maintenance is important for its sustainability .
Limitations of automated testing
one side , The limitations of automated testing are reflected in the above necessary conditions for its implementation , If the necessary conditions are not met , Implementing automation will find that automation will not improve test efficiency , It may even increase the cost of testing .
on the other hand ,UI Limitations of automation and interface automation ,UI Automation has higher coverage than interface automation （ Interface test failed to overwrite page element , format , data ）, Interface automation comparison UI High expansion for automation , Easy to maintain , Advantages of low cost of problem repair .
Front end automation test
We know UI The premise of automation is to emphasize the stability of the system , Unstable systems lead to frequent automated use case maintenance , This kind of maintenance cost is huge , There will even be items that were originally tested by two people , introduce UI Automation now requires three people to test the situation . Then the system has high stability , How to proceed when the possibility of change is small UI automation ?—— Recommended reference Robot
Framework + Selenium2Library, At the same time, the separation of data and code should be considered in automatic test design , In order to reduce maintenance costs , Improve its scalability .
If the stability of the system is general , There are demand changes , Possibility of page optimization , How to carry out automatic test with high coverage ?—— Recommended reference Robot Framework +
requests( Development of custom key word library ) Interface automation , It also needs to consider the design strategy of separating data from code , meanwhile RobotFramework Data driven support , Use case writing efficiency will be greatly improved . Reuse based on this UI
Recorder( Alibaba open source's zero cost UI Automated recording tools ) Automatic test of the whole page .
last , Full consideration of maintainability , Design of automatic test strategy for extensibility , It can realize automatic test forward , Not only for system stability or regression testing scenarios .