实现了一个判断缺陷严重等级的工具

import tkinter as tk

USER_SCORE = {'高': 20, '中': 10, '低': 5}
SCOPE_SCORE = {'10+ 高': 20, '3-10中': 10, '1-3 低': 5}
LOSE_SCORE = {'崩溃':20, '阻塞':15, '模块失效':10,'单个功能失效':5,'单个功能部分失效':1}
PROBABILITY_SCORE =  {'必然出现':20,'一定概率出现':10,'难以复现':5}
IMPORTANCE_SCORE = {'核心功能':20,'主要功能':15,'一般功能':10,'次要功能':1}

class SoftwareDefectDefinition:
    def __init__(self):
        self.root = tk.Tk()
        self.root.title("软件缺陷定义")
        self.root.geometry("500x280")
        self.obj_list = []

    def create_label(self):

        label_user = tk.Label(self.root, text="用户关注程度:")
        label_user.place(x=50, y=20)

        label_scope = tk.Label(self.root, text="用例的影响范围:")
        label_scope.place(x=50, y=70)

        label_lose = tk.Label(self.root, text="功能的失效程度:")
        label_lose.place(x=50, y=120)

        label_probability = tk.Label(self.root, text="出现概率:")
        label_probability.place(x=50, y=170)

        label_importance = tk.Label(self.root, text="功能重要性:")
        label_importance.place(x=50, y=220)

    def create_button(self):

        button = tk.Button(self.root, text="确定",command=self.echo)
        button.place(x=450, y=220)

    def create_score(self):

        self.user = tk.StringVar()
        self.user.set('高')
        score_dropdown = tk.OptionMenu(self.root, self.user,  '高', '中', '低')
        score_dropdown.place(x=200, y=15)

        self.scope = tk.StringVar()
        self.scope.set('10+ 高')
        score_dropdown = tk.OptionMenu(self.root, self.scope,  '10+ 高', '3-10中', '1-3 低')
        score_dropdown.place(x=200, y=65)

        self.lose = tk.StringVar()
        self.lose.set('崩溃')
        score_dropdown = tk.OptionMenu(self.root, self.lose,  '崩溃', '阻塞', '模块失效','单个功能失效','单个功能部分失效')
        score_dropdown.place(x=200, y=115)

        self.probability = tk.StringVar()
        self.probability.set('必然出现')
        score_dropdown = tk.OptionMenu(self.root, self.probability,  '必然出现', '一定概率出现', '难以复现')
        score_dropdown.place(x=200, y=165)

        self.importance = tk.StringVar()
        self.importance.set('核心功能')
        score_dropdown = tk.OptionMenu(self.root, self.importance,  '核心功能', '主要功能', '一般功能','次要功能')
        score_dropdown.place(x=200, y=215)

    def logic(self):

        user_score = self.user.get()
        scope_score = self.scope.get()
        lose_score = self.lose.get()
        probability_score = self.probability.get()
        importance_score = self.importance.get()

        if user_score == '高' or scope_score == '10+ 高' or lose_score == '崩溃':
            return '致命'
        else:
            total_score = USER_SCORE[user_score] + \
                          SCOPE_SCORE[scope_score] + \
                          LOSE_SCORE[lose_score] + \
                          PROBABILITY_SCORE[probability_score] + \
                          IMPORTANCE_SCORE[importance_score]
            print("分数:"+str(total_score))
            if total_score > 90:
                return '致命'
            elif 90 >= total_score > 70:
                return '严重'
            elif  70 >= total_score > 50:
                return '一般'
            elif 50 >= total_score > 30:
                return '提示'
            else:
                return '建议'
    def echo(self):

        level = self.logic()
        if len(self.obj_list) == 1:
            print("清空啦")
            print(self.obj_list)
            destroy_label = self.obj_list[0]
            self.obj_list.pop()
            destroy_label.destroy()

        label_res = tk.Label(self.root, text="")

        if level == '致命':
            label_res.config(text=level,font=("Arial", 30))
            label_res.config(foreground="red")
        elif level == '严重':
            label_res.config(text=level, font=("Arial", 26))
            label_res.config(foreground="orange")
        elif level == '严重':
            label_res.config(text=level, font=("Arial", 24))
            label_res.config(foreground="blue")
        else:
            label_res.config(text=level, font=("Arial", 20))

        label_res.place(x=350, y=100)
        self.obj_list.append(label_res)
    def run(self):
        self.create_label()
        self.create_button()
        self.create_score()

        self.root.mainloop()


if __name__ == "__main__":
    sdd = SoftwareDefectDefinition()
    sdd.run()

在开发过程中,我们经常会因为缺陷的严重程度不能达成一致而浪费大量的实践在PK。

首先,我们明确自己项目中影响问题严重程度的维度有哪些。

根据这些维度评分来确定问题的严重等级。

然后开发一个工具进行固化。

大家按照程序给出的建议判断严重程度即可,尽可能减少歧义。

  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 1
    评论
评论 1
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值