Independence refers to the degree to which each test case stands alone. That is, does the success or failure of one test case depend on another, and if so what is the impact of the sequence of execution? This is an issue because it may be necessary or desirable to execute less than all of the test cases within a given execution cycle; if dependencies exist, then planning the order of execution becomes more complex.

独立性是指每一个测试案例所代表的程度。也就是说,一个测试用例的成功或失败取决于另一个测试用例,如果是这样的话,执行序列的影响是什么?这是一个问题,因为它可能是必要的或可取的执行小于所有的测试用例在一个给定的执行周期;如果依赖存在,然后规划的执行顺序变得更加复杂。

Independent data

数据独立

Independence is most easily accomplished if each test case verifies at least one feature or function by itself and without reference to other tests. This can be a problem where the state of the data is key to the test. For example, a test case that exercises the delete capability of a record in a file should not depend on a previous test case that creates the record; otherwise, if the previous test is not executed, or fails to execute properly, then the later test will also fail because the record will not be available for deletion. In this case, either the beginning state of the database should contain the necessary record, or the test that deletes the record should first add it.

如果每个测试用例本身并不参考其他试验验证的至少一个特征或功能,独立性是最容易达成的。当数据的状态是测试的关键时将会存在问题。例如,一个测试用例,行使在一个文件中的记录的删除功能不应该依赖于以前的测试情况下,创建的记录;否则,如果不执行前面的测试,或未能正确执行,然后稍后的测试也会失败因为记录将不可删除。在这种情况下,数据库的任一开始状态应包含必要的记录,或者说,删除该记录应该首先添加试验。

Independent context

上下文独立

Independence is also needed where application context is concerned. For example, one test is expected to commence at a particular location, but it relies on a previous test to navigate through the application to that point.

还需要独立下应用程序上下文有关。例如,一个测试预计开始在特定位置处,但它依赖于以前的测试来浏览应用到该点。

Result independence

结果独立

Again, if the first test is not successfully executed, the second test could fail for the wrong reason. Your test framework should give consideration to selecting common entry and exit points to areas of the application. and assuring that related tests begin and end at one of them.

再次,如果第一次测试没有成功执行,二次测试可能会失败的原因。你的测试框架应该考虑选择一般的入口和退出点到应用程序的区域。并确保相关测试开始和结束在其中的一个。

It is also risky for one test case to depend on the successful result of another. For example, a test case that does not expect an error message should provide assurance that, in fact, no message was issued. If one is found, steps should be added to clear the message. Otherwise, the next test case may expect the application to be ready for input when in fact it is in an error status.

这也是危险的一个测试用例以依赖的另一个成功的结果。例如,一个测试用例,并不期望一条错误消息应提供保证说,事实上,没有消息发出。如果一个被发现,步骤应该被添加到明确的信息。否则,下一个测试案例可以期望该应用程序在错误状态时准备好输入。

If proper attention is paid to independence, the test execution cycle will be greatly simplified. In those cases where total independence is not possible or desirable, then be certain that the dependencies are well documented; the sequence, for example, might be incorporated into the naming conventions for test cases (ADD RECORD 01,ADD RECORD 02, etc.).

如果适当重视独立,测试执行周期将大大简化。在这些情况下,完全独立是不可能的或希望的,那么可以肯定的依赖关系是有据可查;的序列,例如,可能会被并入的命名约定测试用例(ADD记录01,ADD记录02等)。