想开始编写单元测试用例 [英] Want to start writing unit test case

查看:80
本文介绍了想开始编写单元测试用例的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

您好,



我想开始编写单元测试用例。我应该从哪里开始,在创建一个时应该记住什么。编写单元测试用例需要哪些必要字段?

Hello,

I want to start writing a unit test case. From where should i start and what all should i keep in mind while creating one. What are the essential fields needed for writing a unit test case?

推荐答案

Hello gokulkmp,



单位测试用例完全取决于你需要测试的方法功能。

如果你正在测试计算方法(用户定义的函数),那么该方法的功能就像它会添加A和B并输出为AB



所以测试人员会写单元测试用例

1)调用计算方法并通过A作为第一个参数,B作为第二个参数

2)将此方法的输出存储到变量中并检查预期输出为AB如果通过则将测试用例标记为通过其他明智的失败。



使用的预定义变量如Assert.Pass/Assert.Fail



请阅读此



如何使用使用VSTS的单元测试案例 [ ^ ]
Hello gokulkmp ,

Unit test cases is purely depend upon the method functionality you need to test.
Like say if you are testing Calculation method (which is user defined function) and functionality of that method is like It will add "A" and "B" and give output as "AB"

so tester would write unit test case
1) call the calculation method and pass "A" as first parameter and "B" as second parameter
2) store output of this method into variable and check that with expected output as 'AB' if it pass then mark test case as pass other wise fail.

There are predefined variable used like "Assert.Pass" / "Assert.Fail"

Please read this

How to write Unit Test cases using VSTS[^]


这篇关于想开始编写单元测试用例的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆