Requirement:
I want to put a check on the code so that It should execute only when we are not running test cases.
Requirement:
I want to put a check on the code so that It should execute only when we are not running test cases.
You can use C#'s preprocessor directives for this.
void Start()
{
#if (!TEST_CASE)
//Your code
Debug.Log("test cases");
#endif
}
If you want the code in that Start
function to execute, define it at the top of the script and before any using
statement:
#define TEST_CASE
using System;
using UnityEngine;
Because !
is used in the if
statement, the code in that if
statement will only execute when TEST_CASE
is not defined. Simply comment it out if you need it to execute.