jeudi 20 août 2015

Testing conditions that exit the test

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) 
     {
        exit(0); 
    } 
    if(conditionB) 
    {
        exit(0);
    }
}

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

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.

Aucun commentaire:

Enregistrer un commentaire