-3
@isTest
public class testCustomerTrigger {
    Static testMethod void create(){

 list <Customer__c> c = new list <Customer__c> ();
        for(integer i = 0 ; i < 200 ; i++){
          Customer__c custom = new Customer__c ();  
            custom.Phone__c = '999999999';
            custom.Email__c= '[email protected]';
            custom.Name ='anurag';
            c.add(custom);
        }
        insert c ;
        for(Customer__c c2 : c){
            c2.Name = 'anha';
        update c2;
        }
    }
}
4
  • what are you trying to do?
    – Aequitas
    Feb 16, 2018 at 4:50
  • public class customerClass { public void customerTest1 ( list<Customer__c>TN) { scenerio1(TN); } void scenerio1 (list<Customer__c>TN) { list<Test1__c> test = new list <Test1__c> (); for(Customer__c customer :TN){ Test1__c t = new Test1__c (); t.Name = customer.Name; t.Phone__c= customer.Phone__c; t.Email__c = customer.Email__c; test.add(t); } insert test; } } Feb 16, 2018 at 5:51
  • trigger CustomerTrigger on Customer__c (before Update) { customerClass customer = new customerClass(); customer.customerTest1(Trigger.New); } Feb 16, 2018 at 5:51
  • 2
    posting random bits of code doesn't help anyone. Please try and state what you're trying to do
    – Aequitas
    Feb 16, 2018 at 6:07

1 Answer 1

3

The purpose of test methods are to ensure that other methods are doing what you expect them to.

So in order to answer your question it is first necessary to know what you expect the method under test to do.

Presumably you are attempting to test one or more of your triggers. (Note: You should always try to split up your tests so that you are testing only one thing at a time, ie. in the triggers case, test before update, after update, before insert, etc.).

So then you need to look at what happens in the trigger, if your trigger sets one of the fields to something, then in your test method use assertEquals to test that the object has that value in a field. Maybe you want to just check that no errors are thrown, so in this case you don't need any assertEquals as the test will pass unless an exception is thrown. (or you can assertEquals the message of the exception is what you expect).

But it all depends on what you are doing in the method. Then your test method just calls the method under test and you use assertEquals to check that the effect of the method under test is in fact what you expect it to be.

0

Not the answer you're looking for? Browse other questions tagged .