Keyword-driven and data-driven

Original Transfer from: http: //blog.csdn.net/u010202588/article/details/38639811

 Initial contact with the automated test time, data-driven and keyword driven not understand, so do feel a little mysterious to be, is not a function of its parameters and Well! In fact, it also reflects some of the features of the different tests and development (mainly refers to the system testing), as well as on the context and presentation of technological development.

Myth 1. recording / playback

      In fact, the difficulty can be understood as an automated test scripts and test cases tightly coupled, both test script maintenance, and system testing phase boycott and user-oriented thinking

  Every automated testing tools vendors will publicize their tools are very easy to use, non-technical testers simply recording operation test, then play the recorded test script, you can easily automate all tests. This argument is not very responsible.

  Now we have to analyze automated testing can not rely solely on the reason why the recording / playback to complete.

  Script by recording the established, basically a scripting language to write a hard-coded way, when the application changes, these also will need to change the hard-coded. Therefore, maintenance of these recorded script, the cost is very high, high enough to barely acceptable.

  All test scripts must be recorded before the application can be executed correctly, if a defect is discovered during recording. Testers must report the defect management mechanisms, until the defect corrected, the entire action recording scripts to continue. In such a case, if only rely on recording a script for testing, the efficiency is very low.

  At the same time, the recorded script is not very reliable, even in the case of direct broadcast applications did not change, but also because of some unexpected situations may not be performed. If you record a script tester using the wrong language script, the script must be re-recorded.

  In summary, to create automated test scripts by the way they were recorded sounds easy, but actually experience the following problems: ① most testers do not have a technical background, it is difficult to fully grasp testing tools; ② applications must reach a certain stability, in order to start recording the test script; ③ test scripts and test data recorded coupled too tight; ④ cost of maintaining automated test scripts is very high.

2. Data-driven test automation framework

     "What is a data driven it? Certainly think a large part of the data driver is required to parameterize the things written in EXCEL, and then called when running the script. If I tell you, this is actually not data-driven, but only the more advanced parameterization, you will certainly be surprised now let me explain:! first, why is it called data-driven it, then it must have driven meaning, for example, you use EXCEL can control traffic flow tests do answer is not that how?. driving done it? so we'll test data in a separate file, then just advanced parameters. the data-driven, you have to have data to control traffic flow testing. for example, you measure a WEB program, there are many pages, you can be controlled by a data every time a work in which the page (ie the corresponding page to navigate through the data to). it is a lower key version of the driver, his control is a function of class, and the keyword is control action level. Therefore, the data driver should be able to control the entire test . "

         In some complex test cases, the same use case contains a lot of test flow in which different test procedures different test data input, a control input field at this time is not only the parameter of the test data, as well as business processes input (parameter can be understood as a logical), this case would reflect the data-driven deeper meaning.

  Data-driven automated testing is to test the method proposed for the tight coupling between the development and testing issues. By associating metadata software testing and development defined - metadata mapping table to build loosely coupled relationship between testing and development. Regardless of the test to modify test scripts, or developers to modify the software, only you need to modify the metadata mapping table, both to meet the testing and development simultaneously. In this way, you can reduce the workload of the test script debugging, better automate testing.

  ● What is data-driven automated testing framework

  Data-driven automated testing framework is a framework (e.g. ODBC source files, Excel files, file Csv, ADO object file, etc.) to read the test data input and output from a data file, and then passed through a variable advance recorded or written manual test script. Wherein the variables are used as transfer (input / output) is used to verify the application of the test data. In this process, read, test status and all the test information data files are written into the test script; the test data included only in the data file, instead of the script, the test script is just a "drive", or is a mechanism for data transfer.

  ● data-driven script

      Data-driven script is the script, and those applications associated with it. These scripts are written by hand by recording or writing automated tools proprietary language, then the variable which gives the right values ​​as input test data. These variables media as some of the key input applications, enabled by an external script data-driven applications.

  1) the variable data, hard coded components flag

  These data-driven scripts often contain hard-coded data, some windows are sometimes very fragile component identification strings. When this happens, the script is easy to lose because of a change program of action.

  2) highly technical, design and repeatable test

  Another common feature data-driven script is that all the efforts made in the test design ultimately reflected in the scripting language automation tool, or copied to the manual and automated test scripts. This means that each and automated test development or implementation of the person concerned must be very proficient in programming languages ​​and test environment automation tools.

  ● advantages and disadvantages

  1) Advantages: ① While application development can be synchronized build test scripts, and when the application function changes only need to modify the script-function part; ② using the model of the design, to avoid duplication of scripts, reducing the establishment or maintenance the cost of the script; ③ test input data, verification data and test results with the expected script separately, stored in another data file, which will help testers modification and maintenance; ④ through to determine the function return value is "True" or "False ", it can be used for error handling, increased robustness test scripts; create test data to create data-driven automated testing ⑤ developer testing process, testers; ⑥ test results collected during the test, and in the context of the input data the test results indicated, which can simplify the manual analysis.

  2) disadvantages: ① automated testing tools in the scripting language must be very proficient; ② Each script will correspond to a plurality of data files, data files need to be stored in their respective directories according to functional categories of the script, it adds to the complexity of use ; ③ testers addition to the need to maintain the appropriate test plans based on specific test data, but also writes the data to the different needs of each data file; ④ when editing the data file, you must pay attention to the transmission format required by the test script, otherwise it will an error while processing the script. As maintained by specialized technical personnel to its automated testing framework relies on data-driven script to implement a more simple and fast. However, maintenance is difficult work, but also need to keep this data-driven mode, so even maintain long will lead to failure.

3. keyword-driven test automation

       Keyword-driven nature of sources, from the object-oriented thinking, the same business logic will naturally written as a class or function as a keyword to be called by different test scripts. When testing framework developed to functions and classes all these tests have already been written when the combination is completed, it evolved into an advanced stage of keyword-driven, this time to become a test case development test data and keywords combination, and this combination work to simplify the completion of the task is all very familiar with the form, which ultimately driven by data and keywords throughout the test results.

       In keyword-driven framework, you can create some keywords and some methods and functions associated with it. Then you create a library, it contains a key reading of logic, then call the relevant action.


    Keyword-driven automated testing (also called table-driven automated test), automated test data driven variants, can be supported by different test sequences composed of one or more different paths. It is an application-independent automation framework, while processing an automated test also suitable for manual testing. Keyword-driven test automation framework built on top of data-driven tools, the table contains instructions (keywords), not just data. These tests have been developed to use keyword data tables, they are independent of the implementation of automated testing tools. Keyword-driven test automation improvements and additions are effective data-driven automated testing.

        This model is mainly driven automated testing of engines, components, data from the core function, support libraries and application mapping tables. Automated testing first started by the initial script that passes the high-level test table to the top drive, top drive during the processing of these tables, meet the middle test table after calling middle drive, also made similar when the middle drive handle middle table processing. When the low-level drive process low-level table, which makes attempts to synchronize with the test application. When the low-level low-level driver encountered a key component to a component that determines the type of component and invokes the corresponding function component module to process the instructions. All of these elements must rely on information mapping table, it is a bridge automatic test pattern and test applications. The completion of some major support library file processing, logging and outgoing mail, etc. functions.

Guess you like

Origin www.cnblogs.com/zihkj/p/12563600.html