简体   繁体   English

需要有关如何编写测试用例的建议

[英]Need advice on how to write test cases

I have started to write some test cases today and I would really appreciate some advice here.I have to change a few XML tags in my INI file. 我今天开始写一些测试用例,在这里我真的很感谢一些建议。我必须在INI文件中更改一些XML标签。 Let's say I have one XML attribute which can be either "TRUE" or "FALSE". 假设我有一个XML属性,可以是“ TRUE”或“ FALSE”。 This attribute can apply to two different tags 此属性可以应用于两个不同的标签

<TestOneDir name="xxx" att="TRUE"/>
<TestOneDir name="xxx" att="FALSE"/>
<TestTwoDir name="xxx" att="TRUE"/>
<TestTwoDir name="xxx" att="FALSE"/>

These two tags are within the same test script. 这两个标签在同一测试脚本中。 I wrote test cases to test each condition separately, but I was wondering if I should test for merging conditions, like TestOneDir to be true and TestTwoDir false. 我编写了测试用例以分别测试每个条件,但是我想知道是否应该测试合并条件,例如TestOneDir为true和TestTwoDir为false。

Testing is not black and white so answer to your question is "it depends". 测试不是黑白的,所以您的问题的答案是“取决于情况”。 Often combinations can cause problems that are not seen when testing individual parameters, but you have to assess how likely this is and if it pays to test for this. 通常,组合会导致在测试各个参数时看不到的问题,但是您必须评估这种情况的可能性以及为此进行测试是否值得。 You have to restrict the number of test cases always, but it's just question where to draw the line. 您必须始终限制测试用例的数量,但这只是在哪里划清界限。

Are those conditions related or independent? 这些条件是相关的还是独立的? Do you believe that there could be problems caused by combinations? 您认为组合可能会引起问题吗? Will there be need to refactor this in the future? 将来是否需要重构它? What's worst that can happen if the system is not working in that case? 如果系统在这种情况下无法正常工作,最糟糕的情况是什么? How much longer the running of the tests takes if you add these cases? 如果添加这些案例,测试需要花费多长时间?

I'm no test expert (despite "Test" being in my official job title - don't ask), but with testing you want to ensure complete code coverage: that is to say that all of your tests combined should ensure that every path of execution your program can follow is taken. 我不是测试专家(尽管“ Test”在我的正式职位中-不用问),但是在进行测试时,您想确保完整的代码覆盖率:也就是说,所有测试组合起来应该确保每条路径您的程序可以执行的执行时间。 There are tools you can get that will show you the extent of your test's "code-coverage". 您可以获得一些工具,这些工具将显示测试的“代码覆盖率”范围。

However if you just want to black-box test your code then it helps to reduce your program into a mathematical relation: a defined input and corresponding expected output, then it's just a matter of generating inputs (grouped into equivalence classes) for the range of the program's domain, then comparing the program's output (in an abstract sense) with the expected output. 但是,如果您只想对代码进行黑盒测试,则有助于将程序简化为数学关系:定义的输入和相应的预期输出,则只需生成针对以下范围的输入(分为等价类)即可程序的域,然后将程序的输出(抽象意义上)与预期的输出进行比较。

In your case, you really haven't provided much detail in your question. 就您而言,您确实没有提供太多细节。 You haven't described what your program does, what you're testing exactly, or even why you're declaring tests in XML rather than in code. 您尚未描述程序的功能,正在测试的内容,甚至还没有描述为什么用XML而不是代码声明测试。 To be of more help, I need more information and detail. 要获得更多帮助,我需要更多信息和详细信息。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM