Advertisement
Guest User

TestLink Requirements Delta (All vs Test Plan)

a guest
Jun 15th, 2015
417
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Python 2.21 KB | None | 0 0
  1. import sys
  2. import re
  3. import xml.etree.ElementTree as ET
  4.  
  5.  
  6. ''' Script that parses the html page of a Requirement Based report and returns a list of reqs not in the test plan '''
  7.  
  8. allreqs = open(sys.argv[1])         # Export xml of  all requirements in TestLink
  9. reqreport = open(sys.argv[2])           # html source of Requirement based report for ASIC testplan
  10.  
  11. class Requirement:
  12.    reqtag = ""
  13.    reqtitle = ""
  14.  
  15.    def __init__(self, tag, title):
  16.       self.reqtag = tag
  17.       self.reqtitle = title
  18.  
  19.  
  20. tl_reqlist = []
  21. all_reqlist = []
  22.  
  23. counter = 0
  24.  
  25. print "####### ASIC Test Plan Requirements #######"
  26.  
  27. for line in reqreport:
  28.     match = re.findall("(?:Requirement)[^!]*a>\s([^!]*)", line)
  29.     if match is not None:
  30.         for p in match:
  31.             counter = counter + 1
  32.             req = p.rstrip('","<').split(":")
  33.             print str(counter) + ". " + p.rstrip('","<')
  34.             plan_req = Requirement(req[0].rstrip(), p.rstrip('","<'))
  35.             tl_reqlist.append(plan_req)
  36.  
  37. reqreport.close()      
  38.  
  39. print "####### All Requirements #######"
  40.  
  41. tree = ET.parse(allreqs)
  42. root = tree.getroot()
  43. count2 = 0
  44. for child in root:
  45.         if child.tag == "req_spec":
  46.             for subchild in child.findall('requirement'):
  47.                     #print "ding"
  48.                 if subchild.find('status').text != "O" and subchild.find('status').text != "N":
  49.                     count2 = count2 + 1
  50.                     req = subchild.find('docid').text# + " : " + subchild.find('title').text
  51.                     print str(count2) + ". " + subchild.find('docid').text + " : " + subchild.find('title').text
  52.                     all_req = Requirement(req, subchild.find('title').text)
  53.                     all_reqlist.append(all_req)
  54.                
  55. tl_reqlist.sort()
  56. all_reqlist.sort()
  57.  
  58. rest = [elem for elem in all_reqlist if elem not in tl_reqlist ]
  59. rest = list(all_reqlist)
  60.  
  61. for req in all_reqlist:
  62.         for tp_req in tl_reqlist:
  63.                 if req.reqtag == tp_req.reqtag:
  64.                         rest.remove(req)       
  65.  
  66. rest.sort()
  67.  
  68. print "####### Delta Requirements (not in the test plan) #######"
  69.  
  70. restcounter = 0
  71. for item in rest:
  72.     restcounter = restcounter + 1
  73.     print str(restcounter) + ". " + item.reqtag + " : " + item.reqtitle
  74.    
  75. print "Total # of reqs is " + str(count2) +" where "+ str(counter) + " are in the Test Plan and "+ str(restcounter) + " are not"
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement