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
Bhushan Singh 13Bhushan Singh 13 

while deploying using Force.com migration tool getting 0% code coverage

Hi ,

I am using Force.com migration tool , I have been created Apex class and Test class, in Force.com IDE test coverage is showing 100%  but while deploying its failling and throwing the error 0% code coverage. Please help me if any one has idea about that.

Thanks & Regards
Bhushan Singh
Raj VakatiRaj Vakati
Hello Bhushan,
By Default, salesforce will run all local test classes when you are running the test classes. Please share the error message to find the reason. I thinking that your test class is failing in prod. 
 
David HalesDavid Hales
ou can force a run of all tests when deploying using the Force.com migration tool which is a wrapper over Ant. Set runAllTests=true when deploying to simulate a production like deployment where all tests are run while deploying. To rollback if test classes fail, set the rollBackOnError deployment option to true.
Here is the reference documentation, look around page 17 (Deploying Code)http://www.salesforce.com/us/developer/docs/daas/salesforce_migration_guide.pdf
Thanks and Regards 
Rishi(1044)

Kloudrac Software Private Limited
Bhushan Singh 13Bhushan Singh 13
Hi ,
I am deploying in the developer organization , please find the error below - 


C:\salesforce_ant_38.0\sample\build.xml:60:
*********** DEPLOYMENT FAILED ***********
Request ID: 0Af2800000cq2kPCAQ

Code Coverage Failures:
1.  Class: ApexDemo -- Test coverage of selected Apex Class is 0%, at least 75% test coverage is req
uired
*********** DEPLOYMENT FAILED ***********
KGDevKGDev
Have you tried migrating using Change Sets?
Vinuthh SVinuthh S
Hi Bhushan

Kindly check all the Fields which used in the Classes are present in the Production, Second try to deploy using the Change set using Run Specfied Test using the Test Class Name.

Thanks
Vinuthh S
GauravGargGauravGarg
Hi Bhushan,

Are you using Sandbox "Data" to cover test class? Please create your own data in test class to deploy. 

Thanks,
Gaurav
Bhushan Singh 13Bhushan Singh 13
Hi Gaurav,
actually i am trying to deploy in Developer Organization and i have created the own data in Test class, please verfy it .

public with sharing class ApexDemo {
   
    public static Integer getCalculatedValue () {
        //Method definition and body
        //do some calculation
        
          Integer myValue = 0;  //Class Member variable
          String myString = 'myvalue'; //Class Member variable
    
        
        myValue = myValue+10;
        return myValue;
    }
    
}


Test Class - 

@isTest
public  class ApexDemoTest {

    
    public static testmethod void getCalculatedValuetest()
    {
        ApexDemo apd = new ApexDemo();
         System.assertEquals(getvalue(), ApexDemo.getCalculatedValue());
    } 
    public static Integer getvalue()
    {
        Integer myValue = 0;  
        String myString = '';
         return myValue+10;
    }  
}

Thanks & Regards
Bhushan Singh
GauravGargGauravGarg
Hi Bhushan,

It seems fine,

Could you try re-uploading, sometimes in salesforce it didnt run test class properly. 

Thanks