Test efficiency Optimization Case----Multi-national language Automation Verification Tool (Python) __python

Source: Internet
Author: User
Tags python script

Sharing today is a test gadget written in the quality assurance process-multi-country language calibration background:

1. Our app supports multiple languages, language files are dynamically pulled through the server, and the language of the server is added by the operator manually, the integrity is not guaranteed, and integrity will cause you obviously use German, the result is the embarrassing event of Chinese
2. Because it is a multinational language, it is necessary to rely on the translation company to translate localized Chinese into XX country, our language file uses format character:%s such a format string, but is to the translation company, the result of return often appears% s such result, The result is that the client uses these strings directly crash the problem analysis:

To solve the 1 and 2 checksum problems, before the operation of the classmate Manual check, the accuracy is very low, and often have a customer service to find I said that there is a user feedback language inaccurate or a language use will suddenly crash, and then was dragged by hand, hundreds of thousands of translation Manual Check the head on the big.
Manual is not natural to think of automated calibration, after analysis of 1, 2 problems I think through automated calibration is feasible, and can significantly improve the efficiency of the project. project design:

The first thought is to use the HTML+JS solution, so that the entire project team can be used, and very convenient. Can also be written as an Android project, the handset side direct checksum. The first two can solve the problem, but only do the automatic verification, but did not do automated validation, and then decided to use the Python script to resolve, continuous integration through the Jenkins directly invoke the Py script, very convenient. Problem Solving:

Say dry, first we analyze the process to be implemented:

Other modules are very basic processing, using the requests, ZipFile, xml.dom.minidom these modules
I will highlight the process of parsing and validating.
The XML format is consistent with Android's resource format and is a standard XML language

<resources>
    <string name= "Selector_title" >choose%1$d-%2$d photo (s) </string>
    ...
    ...
</resources>

Since the checksum is required to load all, so using DOM parsing, Python provides us with the Xml.dom.minidom module, we need to get the name and value values above, and then use a dictionary as the storage structure:

def changexmltodict (_path):
    dict = {}
    domtree = Xml.dom.minidom.parse (_path);
    Collection = domtree.documentelement
    strings = Collection.getelementsbytagname ("string") for
    s in strings:
        dict[s.attributes.get (' name '). value] = s.firstchild.data return
    dict

Convert all the XML files, the next is the verification module implementation, we need to implement the following two logic: to find the key value of the most XML file, as the parent file, the other files in turn and this file to traverse all file value, verify the correctness of%s format character channeling

1 logic is very simple, Python provides the Max function, you can calculate the number of XML keys, and then take out the comparison of key and the parent file key to determine the existence of OK.

def checklack (MAX_PATH, Cur_path):
    l_result = []
    D0 = changexmltodict (MAX_PATH)
    D1 = changexmltodict (cur_ Path) for
    k,v in D0.items ():
        if k to D1:
            l_result.append (k) return
    L_result

2 logic is not difficult, directly through the regular judge every value on the OK

def checkvalidate (Cur_path):
    l_result = []
    flag = True
    D0 = changexmltodict (cur_path) for
    k,v in D0.items ():
        If not Re.findall (' \d+ (%\s+) ', v). __len__ () = = 0:
            l_result.append (k)
            flag = False
    return flag,l_result;

And then the last step, to generate HTML, the way I use it is direct code substitution:

basehtml = ' '

Of course, you can also use what jinia2 these frameworks.

Generated HTML report

Results:

Cough, the second column of the HTML report table is the missing field, analysis of these key values found to be a version of the online function, because too late to translate hastily on the line caused by the lack of integrity, the results came out after I and products are stunned.
The third column is a translation company%s checksum exception, basically a field on behalf of a module, I verified the next these, the module under the specific language gorgeous crash, this did not dare to say out, estimated will be beaten, hurriedly secretly change the bug to ... Continuous Integration:

Run Needless to say, the execution of the time only need to use the Jenkins to execute the entry function of the code can be
trigger conditions can be defined according to the version number of the interface, when the need for client updates, the interface will be issued version versions, Jenkins can set the time to check the timing of polling, When version number > last build saved version, the test is performed.

Related Article

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.