You need to sign in to do that
Don't have an account?
sandeep varma indukuri
What is TestScripting in Sfdc
Is there any other techniques of testing rather than Unit testing
function readOnly(count){ }
You need to sign in to do that
Don't have an account?
Defining classes of test methods with the isTest annotation
Class must be private
Use the isTest class annotation to define classes that only contain code used for testing your application
@isTest
private class Test_class {
code_block;
}
Test methods are declared with the following syntax:
static testMethod void test_name() {
code_block;
}
When you create a test method,
Use static
Use testMethod keyword
Use void return type
No any arguments
No data changes performed in a test method
Don’t send emails
The key methods to use in your unit tests are the system.assert() methods:
System.assert(condition)
System.assertEquals(x,y)
System.assertNotEquals(x,y)
Test methods cannot be used to test Web service callouts. Web service callouts are asynchronous, while unit tests are synchronous.
Salesforce.com recommends that you write tests for the following;
Single action
Bulk action
Positive behavior
Negative behavior
Restricted user
Best Practice for writing Test Classes
·Write fully portable tests ·
Don’t use production data in your tests ·
Test expected behavior first, then test unexpected behavior ·
If you find a bug, write a test to expose it before you fix it ·
Shoot for 100% coverage ·
Don’t rely on Today() ·
Put your tests on the controller and class, not in separate classes
http://gokubi.com/archives/testing-best-practices
Thanks,
Rajesh