Relative Content

Tag Archive for cunit-testingstatic-variables

Testing functions with static variables in C

I have a problem performing several scenarios one by one in unit testing. I’m testing a function, where static variables are used and they store states of variables after previous test scenarios. Is it a common problem during testing? An example of simple code below which will shed light on the issue. Of course in the second test, the result fails. I know that the solution could be to create the external variable, which will be passed through a parameter pointer to the function I will have control over this variable and I can set the initial value before starting testing, but in more complex functions where there are many variables is not convenient. Is there any way to run each test as if it were a new process?

Testing functions with static variables in C

I have a problem performing several scenarios one by one in unit testing. I’m testing a function, where static variables are used and they store states of variables after previous test scenarios. Is it a common problem during testing? An example of simple code below which will shed light on the issue. Of course in the second test, the result fails. I know that the solution could be to create the external variable, which will be passed through a parameter pointer to the function I will have control over this variable and I can set the initial value before starting testing, but in more complex functions where there are many variables is not convenient. Is there any way to run each test as if it were a new process?

Testing functions with static variables in C

I have a problem performing several scenarios one by one in unit testing. I’m testing a function, where static variables are used and they store states of variables after previous test scenarios. Is it a common problem during testing? An example of simple code below which will shed light on the issue. Of course in the second test, the result fails. I know that the solution could be to create the external variable, which will be passed through a parameter pointer to the function I will have control over this variable and I can set the initial value before starting testing, but in more complex functions where there are many variables is not convenient. Is there any way to run each test as if it were a new process?