+ Start a Discussion
suresh143suresh143 

Need test class for this one

trigger trgopp2 on Opportunity (before insert,before update) {

for(Opportunity opp:trigger.new){ if(opp.Name != null){ user usr=[select id,name from user where id =: opp.ownerid]; opp.Owner_field__c=usr.name; } } }

Shweta_AgarwalShweta_Agarwal

@isTest
public class trgopp2Test {
    static testMethod void trgopp2 () {
        Opportunity opp1 = new Opportunity();
        opp1.name = 'Test 1';        
        opp1.Type = 'New Customer';
        opp1.CloseDate = system.today();        
        opp1.StageName = 'New Opportunity';
        insert opp1;        
    }
}

suresh143suresh143
There is no code covearage showing 0
Shweta_AgarwalShweta_Agarwal

Check the debug log is it its throwing any error ,  because its giving 100% code coverage for me

suresh143suresh143
hi I have one one req create record in opp object automatically counted that opps in account object field name is no of opp through trigger pls give that one
suresh143suresh143
Ihave an account object there is one field no of opportunitys.once i had created new record with account and no of opportunitys count displayed in Account object field like no of opportunitys in detail page
suresh143suresh143
Once i have created record in account object and automatically created releted list contact record created how to achive this