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
nani@rnani@r 

How to use @istest?

Hai  iam confused about @istest class program can u tell about that with example 

Best Answer chosen by Admin (Salesforce Developers) 
SabrentSabrent

@isTest is an indicator that the code in the class or the code inside a method is written for testing the application.

 

For examples you can read these articles/blogs -



http://www.salesforce.com/us/developer/docs/apexcode/Content/apex_classes_annotation_isTest.htm
http://shivasoft.in/blog/salesforce/step-by-step-salesforce-tutorial-%E2%80%93-creating-trigger-and-test-cases-%E2%80%93-6-of-6/

All Answers

SabrentSabrent

@isTest is an indicator that the code in the class or the code inside a method is written for testing the application.

 

For examples you can read these articles/blogs -



http://www.salesforce.com/us/developer/docs/apexcode/Content/apex_classes_annotation_isTest.htm
http://shivasoft.in/blog/salesforce/step-by-step-salesforce-tutorial-%E2%80%93-creating-trigger-and-test-cases-%E2%80%93-6-of-6/

This was selected as the best answer
nani@rnani@r

thanx for ur information i have one more doubt about "assert" .pls help me about  "assert".

nani@rnani@r

@istest
private class TestTriggers {

static testMethod void myUnitTest() {

Course__c c = new Course__c();

c.Name = 'SFDC........';

c.Fee__c = 20000000;

delete c;
}
}

i have this program but i can't delete that record pls help me for delete record . i want to delete record how can i aproach throw delete statement 

Devendra@SFDCDevendra@SFDC

To delete the record, you first need to write insert statement.

 

Once the record is inserted then you can perform delete operation.

 

System.assert : http://th3silverlining.com/2010/09/07/salesforce-system-assert-vs-system-assertequals/

 

Hope this helps :)

 

Thanks,

Devendra

nani@rnani@r

thanx for ur great information .pls teach me about related lists in salesforce 

nani@rnani@r

actually i am doing shopping mall project. in that i created data model about project.but in the goods i want to less today's sales records of the products.In product object i have taken some fields like jewelry,clothing store , coffee shop, electronics .these products have stock object, in dat object i stored some products. now i want to see net available stock.   

nani@rnani@r

how we execute batchapex in developer console can u reply me 

SabrentSabrent

@Nani, Your last two questions are new and unrelated to the original question. It's best to post these questions in new thread. By posting in the same thread, everyone may not read the questions and also it's a bit confusing to follow through.

 

 

nani@rnani@r

thanx 

spandana@sfdcspandana@sfdc

generally we use the assert in the test classes...'assertEquals' is used to compare the required field value with field or variable...

standard syntax is

system.assertEquals('field value', fieldname/variable name);