当前位置:网站首页>How to write a high-quality test case?

How to write a high-quality test case?

2022-08-10 03:33:00 jinbuer

前言

这篇文章主要是想要写给测试小伙伴们的,因为我发现还是有很多小伙伴在遇到写测试用例的时候无从下手,我就想和大家简单的聊聊,To share some of my opinions and experience.

Cases of five elements,:

  1. 用例标题
  2. 前置条件
  3. 测试步骤
  4. 期望结果
  5. 后置条件

From the perspective of the five elements below,To analyze how to write the test case

用例标题

Use case title is the name of the test point.Use case title is used to illustrate the use case testing purpose,Good title for a use case is the other people see you after this case title, you will know what this use case is measurement.But not the title: the more detailed, the better.Now that is a title,就要言简意赅,Can be more concise and more concise,But simple and can reflect your testing purpose.The title of the cases had better not exceed30个字,Too long can let a person look tired also is not very professional.Can generally follows the formula:主体(可省略) + 动词 + 名词 + 结果(可省略)(What is the effect of the who did what),But most of the time is a verb + 名词的形式.要注意:We write every case is corresponding to test a point.In fact, every point is the operation of the user a behavior.

前置条件

A precondition of a use case isBefore measuring the use case you'll have to prepare the environment and the data.同时,We need to distinguish the preconditions and testing steps,But how to distinguish,Vague or not?We, from the perspective of the use case title,Our cases title is action+A noun?,That our test will focus on the action,That produce this action before all the environment and the data is precondition,The action and the consequences of this action is test steps.这样是不是就比较清晰了. Precondition is that need to prepare the environment to test the cases and data,So the precondition need not to write so detailed as steps,But not too simple,不能有歧义.

测试步骤

Test step is the essence of a use case,Use case title reflect the purpose of the test,Use case steps isHow to measure so as to achieve the purpose of the test.Now that is a step that is the process step by step,But this process is not to write the more detailed, the better.Our steps is to reflect our test purpose,That got to do what,After the operation how to check the result of.This operation may be a step,May also be a few steps,May also be a loop back and forth.No matter what operations are tell others how to do,How to check.But can't write too detailed steps,如【登录控制台,打开xx页面,点击xx按钮】This is not necessary to write it,Because this is not only a waste of time also can give case maintenance cost.Just lean explicitly tell others where do what operation can be,同时,When writing case, you need to follow some rules:

  • 用例规范

  1. Each folder cannot be more than10个测试用例
  2. Each use case step cannot be more than8步(Calculate the entire case test steps,Such as test steps and postconditions perform1-3步)
  3. Test cases do not write“编号”和“测试步骤名称”
  4. Each test case a test point,Use case title shoulds not be too long,Need to streamline and clear
  5. Detailed test requirements point、Testing procedures and results must reflect the expected goal and test the key
  6. The test cases need to use the attachment,Need to attach a file, and file storage path;(The attachment is more than1M可指定路径)
  7. Expected results to quantify and direct,To reduce the communication case execution cost
  8. Test case design should be considered when the test execution efficiency,Function case execution10分钟原则:Use cases in the use of data or samples、Scripts need to be in the note enclosed
  9. “测试步骤”和“预期结果”Must can be realized and the executable
  10. The test cases to verify customer business,Can not only check the configuration and the page,Unless test for pure page
  11. Reflect strong correlation,Remove the weak link;强关联:Case of lack of this step cannot achieve case;弱关联:Case of lack of this step can achieve case;For everybody knows or should know the point not reflected in the use case
  12. Verifying test cases need to be positive and negative contrast:Comparison and off、匹配和不匹配对比、The output of contrast, etc,This use case can merge,Reduce the use case redundant
  13. Prompt content don't write too specific,State general meaning,Later changed the warrant rework cases
  14. The case must be in specific version number
  15. Module note details as much as possible,To test and observing test point
  16. Test method which can realize,Close to the test data in the user environment
  17. And other functions、Associations between the third party test scenarios have missing
  18. Title to streamline,Need to reflect test purposes
  19. Module in the directory note detailed enough,To support other people quickly understand the features and improve the efficiency of test
  20. The results of the tests to check for standing in the perspective of the customer for testing and validation
  21. Page test need cover many browser test
  22. Don't put all the checkpoints on a use case,It will appear to perform leak test or front failed behind don't perform,Lagging problem found
  23. If multiple case on the steps is to cover each other between,需要合并:Such as measuring the longest characters and contain special characters of these two test points can be combined into a case
  24. In the case can't appear ambiguity word,This need clear,Can't perform the same two people Case may produce two execution result
  25. Use cases need professional,Can't appear the colloquial words;
  26. Expect the result need clarity,Can't appear fuzzy words;如可能、如果、Conform to the requirements, etc
  • Maintainability specification

  1. Test cases can't appear in the page configuration path,如:系统配置-网络配置-网络接口
  2. Test cases cannot appear in operation process,比如打开XX目录下文件,点击什么;Write directly to do the operation can
  3. Test cases need to routine checkpoint、Public checkpoint、后台、调试、Configuration file check methods, such as unified wrote module note

期望结果

Expect the result is corresponding test steps,Each test step corresponding to a desired result,Is done after the operation,I hope it the consequences.That you saw in the case of test steps in the1,2,3The results of corresponding expected1,2,3.In theory, every test step requires a corresponding expectation result,But some of the test steps we don't pay attention to this step operation consequences,That such expectation result can write not write.

Note here expect two words,Expect mean to from the perspective of the user,After I made the user operation,I hope it can give me the result of the feedback.This result is not the result of development program code returns,Development program code returns as a result of the actual results,When performing a use case only cases expected results are in agreement with the actual results results,Case to thepass.So when writing case or perform case,Actual results and expected results are obtained when inconsistent, do not easily be developed fooled,All to user home.

后置条件

With the precondition corresponding,即Performed after the use case need reductive environment,Otherwise it will affect the next use case.Write a general functional use case,Postconditions basic need not too concerned about,Because the test environment was needed to diversify to simulate a user environment,If each use case keep a pure environment brings the test workload too big,And also can't very well reflect the diversity of test environment.Postconditions are generally automation needs to be done,The independence of the need to keep the environment as a result of automation,彼此不依赖,Execution after a case needs to be the case created data、Strategies such as all empty,To prevent a case under the influence of.

How to divide case level

Now use case level is how to divide?

Generally in a module in the case according to the level of division,Follow the proportion of:

  • BVT(10%):The most basic function of module to verify(Contains common deployment、Basic relation),推荐1Level use case20%左右
  • Leve1(30%):The basic demand point,基本逻辑,The basic reliability,Basic relation,Basic user scenarios
  • Leve2(40%):常见功能/Logic elaboration point/Special elaboration point,Common associated/容错/边界值/用户场景
  • Leve3(20%):错误提示,Few test cases,Very see deployment way/用户场景/容错/边界值等

When we are in use cases divided into level,为什么要这样划分?

BVTThe case should be the most fundamental and most simple case,As a function module of authorization is the most basic;

level1Basic operation is the basic functional requirements related to,As said above revised increase,May increase many ways,BVTOnly the most basic operation,level1是对BVT的一种补充;

level2Are some internal logic elaboration point or some of the common abnormal operation.Level2The exception is is more common for users to,Is a big probability will meet;

level3Is possible but there is little probability of some operation or abnormal scene.level3Exceptions are very extreme abnormal,Is a small probability would happen,Such as reboot it.

What is the meaning of this division?

This division is meaningful,Look from the hierarchy, in principle, you knowBVTIs the best perform,Then rank the more difficult the greater the coefficient of,特别是level3这种,Might involve very complex network deployment or very abnormal environment construct.

Case need different levels of consumption of the effects of time and is not the same.When one module test,We hope can rapid acceptance of the quality of the module,That how to acceptance?Don't is its basic function is completed,It is basic operations can be smoothly executed,In these basic functions under the condition of basic operations are no problem,To examine the internal logic detail processing is not in place,Finally, examine the processing of all kinds of abnormal situations is already reasonable.That is, from simple to difficult,To safeguard the basic function test other divergent point.

下面是一份非常优质的学习资源,对于做【软件测试】的朋友来说应该是最全面最完整的备战仓库,这个仓库也陪伴我走过了最艰难的路程,希望也能帮助到你!

以上软件测试资料需要的可以私信我都可以免费获取

这还有一份216页软件测试工程师面试宝典文档资料.以及相对应的视频学习教程免费分享!,其中资料包括了有基础知识、Linux必备、Shell、互联网程序原理、Mysql数据库、抓包工具专题、接口测试工具、测试进阶-Python编程、Web自动化测试、APP自动化测试、接口自动化测试、测试高级持续集成、测试架构开发测试框架、性能测试、安全测试等.

学习不要孤军奋战,最好是能抱团取暖,相互成就一起成长,群众效应的效果是非常强大的,大家一起学习,一起打卡,会更有学习动力,也更能坚持下去.

结语

欢迎留言,或是关注我的专栏和我交流.

 

原网站

版权声明
本文为[jinbuer]所创,转载请带上原文链接,感谢
https://yzsam.com/2022/222/202208100201511538.html