+ Start a Discussion
elpaso750elpaso750 

Help with test class - Error Invalid type

Hi,

 

hope to get some help on this. 

 

I have made the following class sometime ago and forgot to create the Test Class :

 

public with sharing class mytest2runedit {

public Testing_Item__c ftt {get;set;}
public Software_Testing__c st {get;private set;} 

ApexPages.StandardController ct;

public mytest2runedit(ApexPages.standardController controller){
	   Tests_to_run__c t2r = (Tests_to_run__c)controller.getRecord(); 
        
       ct = controller;       
       t2r = [select id, Software_testing__c, Testing_Item__c, Completed__c, Compulsory__c, Assigne_to_User__c from Tests_to_run__c where id=:controller.getRecord().Id limit 1];
       
        st = [select id, version__c, Software_to_Be_Tested__c from Software_Testing__c where id =: t2r.Software_Testing__c limit 1];
        ftt = [select id, Software__c, name, Description__c from Testing_Item__c where id =: t2r.Testing_Item__c limit 1];
}

public PageReference save()
 {        ct.save();
         return ct.view();
             }
}

 which is working fine, just letting parent records field show up on child record page.

 

Now in hurry to create the test class and getting an invalid type error:

 

    static testMethod void Test_run_edit(){
          // TO DO: implement unit test
        
               // setup a reference to the page the controller is expecting with the parameters
        PageReference pref = Page.Test2Run;
        Test.setCurrentPage(pref);
        
         // create new Software_Testing__c record
        Software_Testing__c po = new Software_Testing__c();
        po.Expected_Test_Complete__c = Date.newInstance(2020,01,01);
        po.Version__c = '4.3.25';  
        po.Platform__c = 'CMF'; 
        po.Software_to_Be_Tested__c = 'MTS Multimarket';
        insert po; 
    
        // create new Testing_Item__c record
 	    Testing_Item__c ti = new Testing_Item__c();
 	    ti.Description__c = 'My Testing Item';
 	    ti.Def_Compulsary__C = true;
 	    ti.Platform__c = 'CMF';
 	    ti.Software__c = 'MTS Multimarket';
		insert ti;	    	
    
        // create new Tests_to_run__c record
 	    Tests_to_run__c tr = new Tests_to_run__c();
 	    tr.Software_Testing__c = po.id;
 	    tr.Testing_Item__c = ti.id;
 	    tr.Compulsory__c = true;
		insert tr;	    	    
    
            // Construct the standard controller
        ApexPages.StandardController con = new ApexPages.StandardController(tr);
 
        // create the controller
Here is where I get the error  
    mytest2runeditController ext = new mytest2runeditController(con);
 
        // Switch to test context
        Test.startTest();
     
        PageReference ref = ext.save();
        // Switch back to runtime context
        Test.stopTest();
    
    }

 

 

Any suggestion, please ?

 

Alex

elpaso750elpaso750

:-)

 

changed to

 

mytest2runedit ext = new mytest2runedit(con);

 

and got 100%