You need to sign in to do that
Don't have an account?
Abhishek Prasad 8
if clause in apex
I am stuck with this if clause in my Test Clasuse. Can anybody help me. Here is my code example
public MethodName(ApexPages.StandardController Controller){ Newflag = false; //(variable Initialized as false) if(Newflag ) { // Do some stuff } //No else present or needed in this case. } When i am trying to pass this method by calling MethodName in my test class, and initializing the Newflag as true in the testclass, it not getting passed, as NewFlag is already initialized as false in the main class, and the testclass flag is getting overwritten by false. What should it do here
You are intializing the variable in Constructer and immediately you are checking that as true or not?.. In real time scenario it'll not happen. Can you give us the exact requirement of this..
Regards,
Vijaya Amarnath.
Thanks for the reply. I am not setting this variable in constructer. its inside one particular method named MethodName. I am setting a variable with false value. next, when i check an if clause with the same value as true. WHen i am writing a testclass for such a scenario, the if portion is not passing as it the value in the main class is set as false. its not taking the value i am setting in testclass.
Please inform if i am making my self clear
Can you share your code?..