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
Abhilash DaslalAbhilash Daslal 

i am getting the message - 0/1 test methods passed

I am able to save the code, when i run the test class,it gives the error - 0/1 test methods passed

Please help..

Controller class
--------------------
public without sharing class ClsCustomController{
    public List<myCustomObject__c> mylist{get; set;}
    public myCustomObject__c myObject{get;set;}
    public Id myId{get;set;}
        
    public ClsCustomController(){
        myId = ApexPages.currentPage().getParameters().get('id');
        mylist = [select ID,Link__c,Product__c,Hierarchy_Name__c ,Item_Position__c,Primary_Product_Group__c ,
                          Probability__c ,Quantity__c ,
                          NetPrice__c,LineStatus__c ,
                          Validated__c,Line_Item_Id__c   from myCustomObject__c where  
                          Proposal__c =: myId];
        
        
    }
    public ClsCustomController(ApexPages.StandardController controller){
        qte = (myCustomObject__c)controller.getRecord();
        mylist = [select ID,Link__c,Product__c,Hierarchy_Name__c ,Item_Position__c,Primary_Product_Group__c ,
                          Probability__c ,Quantity__c ,
                          NetPrice__c,LineStatus__c ,
                          Validated__c,Line_Item_Id__c   from myCustomObject__c where  
                          Proposal__c =: myId];
        
       
    }

}
---------------------------------------------------------------------------------------
test class 
----------------
@isTest(SeeAllData=true)
public class ClsCustomController {

static testMethod void ClsCustomController() {

myCustomObject__c myObject = new myCustomObject__c();
    myObject.id = propSO.id;
    myObject.Hierarchy_Name__c = 'Indoor SF6-Insulated Load Break Switch GSec';
    myObject.Item_Position__c ='1';
    myObject.Primary_Product_Group__c = true;
    myObject.Probability__c =Decimal.valueOf(30);
    myObject.Quantity2__c =Decimal.valueOf(30);
    myObject.NetPrice__c =Decimal.valueOf(1000);
    myObject.LineStatus__c = 'Open';
    myObject.Validated__c = true;
    myObject.DerivedFromId__c = 'a2X25000004rSPuEAM';
    insert proposalLineItem;
   
    
Test.startTest();
    
PageReference pageRef = Page.VFCustomController;
Test.setCurrentPage(pageRef);
pageRef.getParameters().put('id',myObject.id);   

ApexPages.StandardController sc = new ApexPages.StandardController(myObject);    
ClsCustomController myClass = new ClsCustomController(sc);
ClsCustomController myClass1 = new ClsCustomController();
Test.stopTest();
        }
}
Amit Chaudhary 8Amit Chaudhary 8
Remove the SeeAllData from your test class and create the test data like below in your test class
@isTest()
public class ClsCustomController {

	static testMethod void ClsCustomController() 
	{

			myCustomObject__c myObject = new myCustomObject__c();
			myObject.id = propSO.id;
			myObject.Hierarchy_Name__c = 'Indoor SF6-Insulated Load Break Switch GSec';
			myObject.Item_Position__c ='1';
			myObject.Primary_Product_Group__c = true;
			myObject.Probability__c =Decimal.valueOf(30);
			myObject.Quantity2__c =Decimal.valueOf(30);
			myObject.NetPrice__c =Decimal.valueOf(1000);
			myObject.LineStatus__c = 'Open';
			myObject.Validated__c = true;
			// Remove below hard coding and create test data
			//myObject.DerivedFromId__c = 'a2X25000004rSPuEAM';
			insert myObject;
			
		Test.startTest();
			
			PageReference pageRef = Page.VFCustomController;
			Test.setCurrentPage(pageRef);
			pageRef.getParameters().put('id',myObject.id);   
			ApexPages.StandardController sc = new ApexPages.StandardController(myObject);    
			ClsCustomController myClass = new ClsCustomController(sc);
			
			ClsCustomController myClass1 = new ClsCustomController();
			
		Test.stopTest();
	}
}

 
Abhilash DaslalAbhilash Daslal
@AmitChaudhary,
I removed SeeAllData=true and removed the hardcoded line as you had suggested, but still facing the same error
Abhilash DaslalAbhilash Daslal
I got the below message when i ran the test class -

code coverage from running this test class was not applied due to a conflicting
Abhilash DaslalAbhilash Daslal
Again stuck with the same message

0/1 test method passed
Amit Chaudhary 8Amit Chaudhary 8
Abhilash DaslalAbhilash Daslal
I tried disabling parallel test executions as suggested, but got the same message.

Maybe there is  problem with the code.please suggest changes to the code
Amit Chaudhary 8Amit Chaudhary 8
Can you please post your full test class which you are using as i can see below code but object of propSO is not there in your test class
propSO.id