美文网首页
一次精准测试实践

一次精准测试实践

作者: 小安静子 | 来源:发表于2016-08-30 19:02 被阅读63次

敏捷模式下迭代频繁,回归测试时总是不知道变动的范围。
Dev 有的时候也不知道他改了哪些东西,影响到哪些节点,或者是很多人改的,彼此不知道。遇到有代码洁癖的,改了别人的代码,大家都不知道。
通常情况是,要么测试范围定小了,遗漏了;要么测试范围过大,付出过多代价。
每次回归,Tester 心里总没底,生怕漏了哪里。
如何才能准确定位到变更范围呢?
作者尝试通过对source code 的变动,来达到了解应用的功能模块变化范围。从而制定回归范围和smoke范围。
现在大多数公司用git, 本文就以git 为例。
在git 中,用这条命令,就可以查看source change log.

git whatchanged

例如:

git whatchanged --since='2 weeks ago' 

就可以得到最近2周所有commit 的信息。

首先对comments 进行统计。进行词频分析。

def get_words_dict(target):    
  table = {}    
  line, number = re.subn(r"\W", " ", target)
  for word in line.split():        
    if table.has_key(word):            
        table[word] += 1
    else: 
        table[word] = 1
  return table

去除无效的词,自己定义一个list:

remove_words = ['the', 'a', 'bug', 'to', 'of', 'so', 'one', 'more', 'we', 'Update', 'app', 'our', 'issue','want', 'work']

def remove_dict(obj, key):
    if key in obj.keys():
        obj.pop(key)

for word in remove_words:
      remove_dict(words_number, word)

这个词库可以根据需要增加。
然后生成一张图表:

def get_words_graphic(wordlist):
    keylist = wordlist.keys()
    vallist = wordlist.values()
    barwidth = 0.3
    xVal = numpy.arange(len(keylist))
    plt.xticks(xVal + barwidth / 2.0, keylist, rotation=90)
    plt.bar(xVal, vallist, width=barwidth, color='y')
    plt.title(u'词频分析图')
    plt.show()

图表展示为:


Screen Shot 2016-08-30 at 7.00.44 PM.png

然后将改动的文件统计出来:


Screen Shot 2016-08-30 at 7.01.12 PM.png

为了防止图片展示不清楚,同时还写一份log.
这样,就可以大概知道改动了。如果懂些代码,可以深入到代码里面去看。或者拉着Dev一起看,确定最终范围。
当然如果Dev的comments 写得够清楚,文件命名很规范,那就更好了。
还可以辅助sourcecode 界面工具辅助查看。

这样,每次回归就不会那么没有底了。
更多精彩,请关注微信公众号: python爱好部落

qrcode_for_gh_ca85abea157e_430.jpg

相关文章

网友评论

      本文标题:一次精准测试实践

      本文链接:https://www.haomeiwen.com/subject/gkfqettx.html