You need to sign in to do that
Don't have an account?
Help Test code not making sense.
I have something strange happening in my test code and I can't figure out what's happening.
I have to following code:
//other code to create O1 exists above.
ApexPages.StandardController sc = new ApexPages.standardController(O1);
cntrCreateCompanyProduct CCP = new cntrCreateCompanyProduct(sc);
CCP.newCP(); //creates a new ComProd varible and loads it.
if(CCP.ComProd != null) system.debug('testing comp is not null');
System.AssertEquals(CCP.ComProd,null);
So I see the debug message in my debug log, which means that CCP.ComProd is not null however the Assert is firing causing my test code to fail at this point?
I'm not sure what I'm missing.
System.AssertNotEquals(CCP.ComProd,null);
All Answers
Hi,
That in red if its a method so do something just above to it, because its unable to find anything, thats why its showing everything null
ApexPages.StandardController sc = new ApexPages.standardController(O1);
cntrCreateCompanyProduct CCP = new cntrCreateCompanyProduct(sc);
/* INSERT YOUR RECORD HERE , EXACT CONDITION FOR THE METHOD "newCP" */
CCP.newCP(); //creates a new ComProd varible and loads it.
if(CCP.ComProd != null) system.debug('testing comp is not null');
System.AssertEquals(CCP.ComProd,null);
don't forget to mark correct with kudos (Start) if the solution helps you
System.AssertNotEquals(CCP.ComProd,null);
Thank you, after reading your post I went and did some more research. I assumed system.Assertequals(comProd,null); would fire if comProd == null. But I guess it's the opposite and it fires if the condition is false.
Thanks Again. I don't see how to mark this as my solution, but it was.
"Options".
Click on it and mark it as accepted.
Regards,
Bhavi Sharma
Certified Salesforce Consultant
bhavi@simplyforce.com/bhawani.sh.sharma@gmail.com
+91-9928130589
LinkedIn |
Twitter
| Blog |
Community
www.simplyforce.com
That's what I figured but I don't have that option.
I can't put in a screen shot but I only have
Mark as New
Bookmark
Subscribe
Subscribe to RSS Feed
Email to Friend
Revoke my Kudos
Report Inappropriate Content.