function readOnly(count){ }
Starting November 20, the site will be set to read-only. On December 4, 2023,
forum discussions will move to the Trailblazer Community.
+ Start a Discussion
asd@as.asdasd@as.asd 

Test Class

hello

         i am new salesforce.i want to write test class for triggers and controller class.

         please help me to write test class

Best Answer chosen by Admin (Salesforce Developers) 
Navatar_DbSupNavatar_DbSup

Please go through this link:


http://th3silverlining.com/2010/02/04/unit-tests-code-coverage-with-the-apex-programming-language/


 http://astreait.com/wordpress/?p=58

 

Did this answer your question? If not, let me know what didn't work, or if so, please mark it solved. 

All Answers

Navatar_DbSupNavatar_DbSup

Please go through this link:


http://th3silverlining.com/2010/02/04/unit-tests-code-coverage-with-the-apex-programming-language/


 http://astreait.com/wordpress/?p=58

 

Did this answer your question? If not, let me know what didn't work, or if so, please mark it solved. 

This was selected as the best answer
asd@as.asdasd@as.asd

hello 

    i am using test,startTest()  and test.stopTest() method in test class.

   i am  facing a error   :

    Method does not exist or incorrect signature: Test.startTest() at line 16 column 9

    my code is : 

       

 

      

@isTest

private class testclass{

public static testMethod void TestOverwriteTestAccountDescriptions(){
// Perform our data preparation.
List<Account> accounts = new List<Account>{};

for(Integer i = 0; i < 200; i++){
Account a = new Account(Name = 'Test Account ' + i);
accounts.add(a);
}

// Start the test, this changes governor limit context to
// that of trigger rather than test.
Test.startTest();

// Insert the Account records that cause the trigger to execute.
insert accounts;

// Stop the test, this changes limit context back to test from trigger.
Test.stopTest();

// Query the database for the newly inserted records.
List<Account> insertedAccounts = [SELECT Name, Description
FROM Account
WHERE Id IN : accounts];

// Assert that the Description fields contains the proper value now.
for(Account a : insertedAccounts){
System.assertEquals(
'This Account is probably left over from testing. It should probably be deleted.',
a.Description);
}
}
}

VishwanathVishwanath

Hi,

 

Make sure that your list of class should not contain class name as 'test',

if any of your class name is test please rename the class name

 

asd@as.asdasd@as.asd

thanks

   now its working