You need to sign in to do that
Don't have an account?
Can any one tell me how to write test class?
Hi everyone,
I want write test class how to write test class
I want write test class how to write test class
You need to sign in to do that
Don't have an account?
Inside the class ,call the method preceded by the @isTest annoatation.When calling, pass the values needed to test the method.
Eg:
@isTest
private class TemperatureConverterTest {
@isTest static void testWarmTemp() {
Decimal celsius = TemperatureConverter.FahrenheitToCelsius(70); System.assertEquals(21.11,celsius); }
comment if having doubt regarding this.
select this as best,if helped you.
Thanks!.
The Apex testing framework enables you to write and execute tests for your Apex classes and triggers on the Force.com platform. Apex unit tests ensure high quality for your Apex code and let you meet requirements for deploying Apex.
I hope this code will help you lot to understand and write test class :
Suppose I have to write Test class this Apex code:
Apex Class :
Test Class Code for Above Apex Code :
Points to remember for Test Classes:
1. Test class always Start with @isTest
2. Test class do not Execute System.debug()
3. test.startTest() and test.stopTest() must be used in Test Class.
For More Information go through these links
https://developer.salesforce.com/page/An_Introduction_to_Apex_Code_Test_Methods
https://developer.salesforce.com/docs/atlas.en-us.apexcode.meta/apexcode/apex_qs_test.htm
http://www.sfdc99.com/2013/05/14/how-to-write-a-test-class/
Let me know if you have any Question.
If you understand, then mark it as best answer.
Thank You
With Regards,
Ajay