+ Start a Discussion
Sanjeev R 1Sanjeev R 1 

Code Coverage for Page refrence code

I have a class named "ctrlMultiClone"
and a constructor to this class as 

private ApexPages.StandardController standardController;
 public ctrlMultiClone(ApexPages.StandardController standardController)
    {
        this.standardController = standardController;
    }

requesting to please guide how to get the code coverage for this part.

As I have a custom buttom on Opportunity page lagout that is using this class for Cloneing Opportunity with Custom related list..
All functionality working as desired execpt the code coveage part for the above code

Thanks in advace
Sanjeev

Balaji BondarBalaji Bondar
Hi Sanjeev,

Use below code:
static testmethod void testm1(){
	Opportunity OpportunityObj = new Opportunity(Name=opportunityName,StageName='Prospecting', CloseDate=Date.today()) ;
	insert OpportunityObj ;
	ApexPages.StandardController con = new ApexPages.StandardController(OpportunityObj);
	ctrlMultiClone cls = new ctrlMultiClone(con);
}

Important :
If this is what you were looking for then please mark it as a "SOLUTION" or You can Click on the "Like" Button if this was beneficial for you.
Sanjeev R 1Sanjeev R 1

Thanks Balaji and Anoop,
that worked...

but while cloning I m getting and error

System.DmlException: Insert failed. First exception on row 0; first error: INACTIVE_OWNER_OR_USER, operation performed with inactive user: []

this is due test Opportunity that I m picking is of Owner that is Inactive..
as this query 
SELECT ID FROM Opportunity limit 1
is returning the first opportunity ID .... unfortunatly that is of a INACTIVE owner

Looking for a SQOL query that returns a single Opportunity ID from the database for an Active Owner