Network Security Internet Technology Development Database Servers Mobile Phone Android Software Apple Software Computer Software News IT Information

In addition to Weibo, there is also WeChat

Please pay attention

WeChat public account

Shulou

Improvement plan for project automation test architecture-separation of instruction information

2025-01-17 Update From: SLTechnology News&Howtos shulou NAV: SLTechnology News&Howtos > Internet Technology >

Share

Shulou(Shulou.com)06/03 Report--

However, after all, our action instruction information is for the designer of the test case data to tell Engine how to modify the original data set, so we have to separate the information, but in the previous step, we have removed these fragments, so how do we get the information? It's very simple, don't we have the original data, so we can parse these action instructions for the original data xml string, a testcase, a testcase and store them in the corresponding Value Object list. In the future, we just need to operate on the original data set correctly according to the information provided in these lists.

The class that separates information is called XMLModifyInfoExtractor, which is responsible for separating actions:

The code is as follows:

/ * extract all the modification information and store to member fields. * @ param filePath * @ throws Exception * / public void extractModifyInfo (String filePath) throws Exception {SAXReader reader = new SAXReader (); Document document = reader.read (new File (filePath)); Element rootElement = document.getRootElement (); String testcaseElementPathValue; Element addElements; Element addElementPath; String addElementPathValue Element addElementValue; String addElementValueValue; Element updateElements; Element updateElementPath; String updateElementPathValue; Element updateElementValue; String updateElementValueValue; Element removeElements; Element removeElementPath; String removeElementPathValue; / / first, get all the element List testcaseElementList = rootElement.elements ("test_case") For (Element testcaseElement: testcaseElementList) {testcaseElementPathValue = testcaseElement.getUniquePath (); / / get part from the addElements= testcaseElement.element ("add_elements"); if (addElementsinvalid null) {/ / traverse the to get a seris of List addElementList = addElements.elements ("add_element") For (Element addElement: addElementList) {/ / extract the information from addElementPath = addElement.element ("path"); addElementPathValue = addElementPath.getTextTrim (); / / extract the information from addElementValue = addElement.element ("value"); String xmlValue=addElementValue.asXML () / / remove the and part from this xml addElementValueValue=xmlValue.replace (",") .replace (","); addElementInfoList.add (new AddElement (testcaseElementPathValue,addElementPathValue,addElementValueValue)) }} / / get part from the updateElements= testcaseElement.element ("update_elements"); if (updateElementsinvalid null) {/ / traverse the to get a seris of List updateElementList = updateElements.elements ("update_element") For (Element updateElement: updateElementList) {/ / extract the information from updateElementPath = updateElement.element ("path"); updateElementPathValue = updateElementPath.getTextTrim (); / / extract the information from updateElementValue = updateElement.element ("value"); updateElementValueValue=updateElementValue.getTextTrim () UpdateElementInfoList.add (new UpdateElement (testcaseElementPathValue,updateElementPathValue,updateElementValueValue));} / / get part from the removeElements= testcaseElement.element ("remove_elements") If (removeElements! = null) {/ / traverse the to get a seris of List removeElementList = removeElements.elements ("remove_element"); for (Element removeElement: removeElementList) {/ / extract the information from removeElementPath = removeElement.element ("path"); removeElementPathValue = removeElementPath.getTextTrim () RemoveElementInfoList.add (new RemoveElement (testcaseElementPathValue,removeElementPathValue));}

Now, after the above three steps, the execution contents of all the action sequences in our code are stored in the corresponding variables.

Welcome to subscribe "Shulou Technology Information " to get latest news, interesting things and hot topics in the IT industry, and controls the hottest and latest Internet news, technology news and IT industry trends.

Views: 0

*The comments in the above article only represent the author's personal views and do not represent the views and positions of this website. If you have more insights, please feel free to contribute and share.

Share To

Internet Technology

Wechat

© 2024 shulou.com SLNews company. All rights reserved.

12
Report