本文介绍了退出测试的测试条件的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我必须测试几个例程/函数,这些例程/函数具有多个if语句,这些语句导致终止测试执行的terminate()或exit()语句.

I have to test several routines/functions that have several if statements that leads to a terminate() or exit() statement that stops the test execution.

我想知道测试这种功能的最佳/正确方法是什么?

I was wondering what's the best/correct approach in testing functions like this?

例如,如果我有以下内容:

For example, if I had something like the following:

void function foo(void)
{
     if(conditionA)
     {
        Terminate( //include infinite while loop resulting in timeout);
    }
    if(conditionB)
    {
        Terminate( //includes infinite white loop resulting in timeout);
    }
}

当我有一个适用于conditionA的测试用例时,如何打中conditionB?

How do I hit conditionB when I have a test case that is true for conditionA?

我认为我必须创建一个单独的测试用例,以使conditionB为true(条件A为false).但是,测试仍然执行conditionA,因为我有两个测试用例正在运行.测试用例1,将进入conditionA并退出测试.Withby测试用例#2,由于测试用例#1而无法运行.

I think I would have to create a separate test case for conditionB to be true (and condition A to be false). However, the test still executes conditionA because I have two test cases run. Test Case #1, will enter conditionA and exit the test. Withby Test Case #2, will not run because of Test Case #1.

那么,我应该如何构建测试范式的流程?

So, how should I structure the flow of my testing paradigm?

目前,我为每个功能都有一个测试套件,其中包含几个测试用例.

Currently, I have a test suite for each function that contains several test cases.

推荐答案

您有2个选项:
1 在单独的过程中运行测试-像检查这样的框架可以轻松地做到这一点为你.

You have 2 options:
1 Run the test in separate processes - a framework like check can do that easily for you.

2 存根违规功能>-通过链接您自己的终止()函数版本或通过使用宏将终止重新定义为您自己的版本.即
#define终止(_dummy_)my_terminate(_dummy _)

这篇关于退出测试的测试条件的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!

09-06 03:38