简体   繁体   中英

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. Let's say I have one XML attribute which can be either "TRUE" or "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.

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. 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. To be of more help, I need more information and detail.

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

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