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

Deployment Woes

hey everyone,


I am trying to deploy an edited version of a class already scheduled in live salesforce.


I am getting the following errors:



I have uploaded many small scheduling tasks and triggers into SF without test classes and they've gone through. However, this time i got a Deploy Error. Is there a work around without having to write a ton of test classes?


I have done extensive testing in the sandbox for my upload and it has been fine. The edits contained in NDA counter are really small for my the already up and running version in live SF.


any help is appreciated. 


if the average coverage is 75% you can deploy but in your case the average coverage is 62%.Write some test classes for them so that the coverage goes up




For your trigger, are you using any test data that is specific to sandbox?

I suspect this might be the problem if your trigger has more than 75% coverage in sandbox and unable to deploy to production.


Let me know how it goes.







I have no idea how to write test classes for batch apex. Or for any apex for that matter.


I have looked at the documentation, but I do not understand what exactly is going on. Does anyone have any tips on how ot learn Apex without taking the class? This is really frustrating for me.


Here is my apex batch class. I have a few that are fairly similar ot it, but none have test classes.



global class countRefContacts implements Database.Batchable<sObject>{
	global final String gstrQuery = 'select ID, Number_of_Reference_Contacts__c from Account';
    global Database.QueryLocator start(Database.BatchableContext BC){
		return Database.getQueryLocator(gstrQuery);
    global void execute(Database.BatchableContext BC, List<sObject> scope){
 		List<Account> listAccount = new List<Account>();
      		for(SObject objSObject : scope){
				Account objAccount = (Account)objSObject;
				Integer intNumberOfRefs = [SELECT count()FROM Contact WHERE AccountID = :objAccount.ID and Email != null and Binary_Reference_Contact__c = 1];
			  	if (intNumberOfRefs <> objAccount.Number_of_Reference_Contacts__c){
			  		objAccount.Number_of_Reference_Contacts__c = intNumberOfRefs;
       if (listAccount.size() > 0 ) {update listAccount;}
    	global void finish(Database.BatchableContext BC){



Here's what i have so far. I dont know what goes in between Test.start and Test.StopTest.


public class testCountRefContacts {
	static testMethod void testCountRefContacts(){
	List<Account> accns = new List<Account>();
	for (Integer i = 0; i<200; i++){
		Account a = new Account();
	insert accns;
	countRefContacts count = new countRefContacts();
	ID batchprocessid = Database.executeBatch(count);