DOCX

Test data structure secrets (1) - exclusive data reference data separation

By Jeanne Carpenter,2015-05-08 21:58
9 views 0
Test data structure secrets (1) - exclusive data reference data separation

    Test data structure secrets (1) - exclusive data reference

    data separation

    Recently watched a few test cases in enterprise data preparation, found a common problem: test data of a large amount of redundancy, the redundancy will bring the subsequent test cases and data maintenance a lot of cost.

    In order to facilitate everybody understanding, first take an example:

    Credit card transaction summary, testing data fully loaded from CSV, each test case according to the data in the CSV, assert specific return value (due to space limitations, here only a simple example. Actually see, CSV, no field information line of hundreds of thousands of data, and there are so many similar structure of the CSV file as test data).

    Csv1

    Csv2

    In the two files, I noticed that there is a lot of redundancy.CSV format of test cases, for example, imagine if the future table structure change (increase or decrease field), so need to modify all the CSV file, will be what kind of work!

    Joe leung translation in continuous delivery: to issue reliable software system method ", has given solution, simply because there is no specific instances, not easy to understand.

    Via He Mian remind, found in his book instantiation demand, also mentioned the similar way of thinking, but also have no instance, :) :

    Let's on the basis of the above example, explain ideas how to specific application of the two books:

    ; Application reference data (Application reference data) has nothing to do is to test data, but they

    are necessary to the Applicationstarts, these data is often refer to some base table and basic data;

    ; Test reference data (Test reference data) are those and Test related, but there is no much impact

    behavior of the Test data, in the following two example, yellow is a testing reference data

    ; Exclusive data Test (Test specific data) : real impact Test behavior characteristics of the data

    To understand the test reference data and test data, the difference between a first secrets, I can introduce test data structure:

    Will test the reference data and test data preparation process of separation, the separation of reusable test reference data preparation, and will test the exclusive data stored in the test script.

    Specific approach is the first example, we suggest that within each test case, first using a public program of testing as reference data for each case, and then will use the UPDATE statement to test the exclusive data import, test case pseudo code is as follows:

    Test case 1

    The reference data from CSV import test

    Test the exclusive data import

UPDATE transactions SET amount = 15.99 WHERE id = 1;

    UPDATE transactions SET amount = 30.98 WHERE id = 2;

    UPDATE transactions SET amount = 75.95 WHERE id = 5;

    UPDATE transactions SET amount = 150.9 WHERE id = 10;UPDATE transactions SET amount = 750.5 WHERE id = 50;

    The test execution

    The validation test (sum is 1024.32)

    Test case 2

    The reference data from CSV import test

    Test the exclusive data import

    UPDATE transactions SET amount = 34.56 WHERE id = 1;

    UPDATE transactions SET amount = 56.78 WHERE id = 2;

    UPDATE transactions SET amount = 57.97 WHERE id = 5;

    UPDATE transactions SET amount = 44.32 WHERE id = 10;

    UPDATE transactions SET amount = 234.65 WHERE id = 50;

    The test execution

    The validation test (sum is 428.28)

    Doing this there are two main benefits:

    ; Test case maintainability: these cases, testing reference data with the use of the INSERT statement,

    it will be affected by changes in the database table structure, but due to the use of proprietary data

    for UPDATE statement, not affected by the database table structure change.We through unified test

    reference data preparation procedures, will greatly reduce the impact of this change, the future data

    table structure change, we need to modify a unified program without having to modify the

    reference data for each case, it coincides with the DRY principle (Don 't repeat yourself).

    ; Readability test cases: because we will test the reference data prepared from independence, as long

    as the test case itself, you can clearly see the test exclusive data, measured behavior and the results

    show, let the case to enhance the readability.

    In order to facilitate everybody understanding, we'll give another example, suppose you have a test currency conversion interface, test inputs is an XML file:

    XML1

    XML2

    Application testing reference data and test data separation principles, you can see what is the reference data, which is exclusive data

    In test cases, therefore, we will prepare for and load a basal XML files, set up exclusive test data, the following is the use of Robot Framework written in two test cases, it can be seen that in the future if there are any changes to the structure of the XML file, we only need to modify the base XML file, without any need to modify the test cases

    Base.xml

    At this point, we think we have understood, for the test data for this step, separate the test reference data and test data, can be very effectively improve readability and maintainability test cases.

    If you are interested, you can join me to set up a "layered test automation" QQ group 20442181 further discussion, or attentionWeChatThe Agile - Testing - China.

Report this document

For any questions or suggestions please email
cust-service@docsford.com