system.assert is just is used for cheking the functionalities that you are going to do in the test class like insertin or updating any object.... For Example--> Contact objcon = new Contact(LastName= 'Test-Contact-1');
insert objcon;
system.assert(objcon.Id != null);
suppose the Contact object not inserted then assert will throw an error so u can say by assert u can get the perfect results what u want....assertEquals also doing almost the same job.....Thanks
These are used widely for executing APEX Test classes, where we compare the output with the expected value. When the values are same assertion succeeds.
Also we use AssertNotEquals when we expect the output to be different where assertion fails if the answers match.
See the detailed description of Assert methods in the article below,
system.assert is just is used for cheking the functionalities that you are going to do in the test class like insertin or updating any object....
For Example--> Contact objcon = new Contact(LastName= 'Test-Contact-1');
insert objcon;
system.assert(objcon.Id != null);
suppose the Contact object not inserted then assert will throw an error so u can say by assert u can get the perfect results what u want....assertEquals also doing almost the same job.....Thanks
Hi Ankit,
These are part of the System methods,
These are used widely for executing APEX Test classes, where we compare the output with the expected value. When the values are same assertion succeeds.
Also we use AssertNotEquals when we expect the output to be different where assertion fails if the answers match.
See the detailed description of Assert methods in the article below,
http://www.salesforce.com/us/developer/docs/apexcode/Content/apex_methods_system_system.htm
Regards,
Ashish
If your question is answered, please mark this post as solved.
Explaination is available here
http://th3silverlining.com/2010/09/07/salesforce-system-assert-vs-system-assertequals/
&
http://wiki.developerforce.com/page/An_Introduction_to_Apex_Code_Test_Methods
and Example
http://www.salesforce.com/us/developer/docs/apexcode/Content/apex_testing_example.htm