You need to sign in to do that
Don't have an account?
Sajila Kadayaprath
What is the use of System.AssertEquals(1,1)
I could see the usage of System.AssertEquals(1,1) in some codes available over internet.
Can anybody explain for what it is used for?
Thanks,
Can anybody explain for what it is used for?
Thanks,
System.AssertEquals(1,1) always return true whatever the result from the code. Then test method will always get passed if there is no exception from the code.
If we use these types of assertions implies that we are just concentrating on the code coverage not on the result.
Regards,
Bhanu Mahesh
All Answers
system.assertEquals method is used to verify that the expected result is returned
System.assertEquals() is used to validate two values are equal. Basically it is used in test method. This method asserts that the first two arguments, x and y are the same, if they are not a runtime exception is thrown.
Please refer the below link
https://www.salesforce.com/us/developer/docs/apexcode/Content/apex_testing_example.htm
Regards,
Bhanu Mahesh
Means the code you are testing is not giving you the expected result. This may be due to problem in your code or with the data you are testing.
You cannot deploy a test class to production if it is failed.
You have to correct the code or data to make the test class pass with expected results which can be checked with System.assertEquals by passing the expexted result and the result from the code as parameters.
So salesforce ensures the corect code being deployed to production after being tested properly.
Regards,
Bhanu Mahesh
System.AssertEquals(1,1) always return true whatever the result from the code. Then test method will always get passed if there is no exception from the code.
If we use these types of assertions implies that we are just concentrating on the code coverage not on the result.
Regards,
Bhanu Mahesh