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
cjmarchi1cjmarchi1 

help!!! unable to deploy SIMPLE trigger to server because of coverage

hello, 

it's been some days now I havent been able to deploy a very simple trigger to server. Now it says that there is no coverage to deploy it (42% so far) whenever I try to deploy to server both my trigger and test class.

I am using Enterprise Edition for nonprofits and Force.com IDE version 25.

Before this problem, I was stuck by this problem described down here: (http://boards.developerforce.com/t5/General-Development/Unable-to-refresh-resource/td-p/205678/page/2
I managed this first problem reinstalling eclipse and force.com IDE, and switching workspaces to the same workspace, and the message error described above disapeared. 

Now I am stuck by this coverage problem: 
************** 
*** Deployment Log *** 
Result: FAILED 
Date: August 21, 2012 2:44:43 PM BRT 

# Deployed From: 
Project name: IDS 
Username: cjmarchi1@uol.com.br 
Endpoint: www.salesforce.com 

# Deployed To: 
Username: cjmarchi1@uol.com.br 
Endpoint: www.salesforce.com 

# Deploy Results: 
File Name: classes/PreencheNomeContaEmContatoClass.cls 
Full Name: PreencheNomeContaEmContatoClass 
Action: UPDATED 
Result: SUCCESS 
Problem: n/a 

File Name: package.xml 
Full Name: package.xml 
Action: UPDATED 
Result: SUCCESS 
Problem: n/a 

File Name: triggers/PreencheNomeContaEmContato.trigger 
Full Name: PreencheNomeContaEmContato 
Action: UPDATED 
Result: SUCCESS 
Problem: n/a 

# Test Results: 

Run Failures: 
CMSConsoleActionsController.t1 System.QueryException: List has no rows for assignment to SObject 
CMSFoldersController.t1 System.QueryException: List has no rows for assignment to SObject 
CMSForceConsoleController.t1 System.QueryException: List has no rows for assignment to SObject 
CMSForceSetupController.t1 System.AssertException: Assertion Failed 
CMSSiteDetailController.t1 System.QueryException: List has no rows for assignment to SObject 
contentblockcomponentController.t1 System.QueryException: List has no rows for assignment to SObject 
FormItemIncludeController.t1 System.QueryException: List has no rows for assignment to SObject 
FriendlyURLs.t1 System.QueryException: List has no rows for assignment to SObject 
HomePageController.t1 System.QueryException: List has no rows for assignment to SObject 
PageBrowserController.t1 System.QueryException: List has no rows for assignment to SObject 
pageController.t1 System.QueryException: List has no rows for assignment to SObject 
PageItemEditExtension.t1 System.QueryException: List has no rows for assignment to SObject 
PageItemIncludeController.t1 System.QueryException: List has no rows for assignment to SObject 
PreviewPageController.t1 System.QueryException: List has no rows for assignment to SObject 
TestCMSForceTriggers.t2 System.QueryException: List has no rows for assignment to SObject 
TestCMSForceTriggers.t3 System.QueryException: List has no rows for assignment to SObject 
TestCMSForceTriggers.t4 System.QueryException: List has no rows for assignment to SObject 
TestCMSForceTriggers.t5 System.QueryException: List has no rows for assignment to SObject 
CleanupUnusedContentBlockItems A cobertura do teste do Apex selecionado Trigger é de 0%. São necessários pelo menos 1% de cobertura do teste 
PreventFolderOrphans A cobertura do teste do Apex selecionado Trigger é de 0%. São necessários pelo menos 1% de cobertura do teste 
PreventTemplateOrphans A cobertura do teste do Apex selecionado Trigger é de 0%. São necessários pelo menos 1% de cobertura do teste 
SetAsHomePage A cobertura do teste do Apex selecionado Trigger é de 0%. São necessários pelo menos 1% de cobertura do teste 
SetHomePageSiteId A cobertura do teste do Apex selecionado Trigger é de 0%. São necessários pelo menos 1% de cobertura do teste 
PreventActiveWebFormDelete A cobertura do teste do Apex selecionado Trigger é de 0%. São necessários pelo menos 1% de cobertura do teste 
A cobertura média do teste em todas as classes e acionadores do Apex é de 42%, pelo menos 75% de cobertura de teste são necessários. 
**************



The code for my trigger:
trigger PreencheNomeContaEmContato on Contact (before insert) { 
for(Contact a : Trigger.New) 
a.AccountId = '001E000000JKUmr'; 
}


The code for my test class:


@isTest 
private class PreencheNomeContaEmContatoClass { 

static TestMethod void PreencheNomeContaEmContatoMethod(){ 
string test0Value = 'testeeeeeeee12345'; 
insereContato(test0Value); 
Contact testObj = [Select Name, AccountId from Contact where Name = :test0Value]; 
System.assertNotEquals(testObj, null); 


private static void insereContato(String field2Value) 

Contact obj = new Contact(); 
obj.LastName = field2Value; 
insert obj; 


}

 

Best Answer chosen by Admin (Salesforce Developers) 
cjmarchi1cjmarchi1

hi guys,

problem solved!!!!

Here is what I just did: uninstalled the CMSForce package from my org (it came along with Salesforce.com), refreshed the salesforce schema on Force.com IDE, and both trigger and test class deployed perfectly to server (100% coverage)....**bleep** CMS package...LOL

 

My trigger had 100% coverage with my test class since the beginning, so the coverage problem was with classes used by this CMSForce package.

 

Thanks for taking your time to help me out.

 

Clarisse

All Answers

Saikishore Reddy AengareddySaikishore Reddy Aengareddy

Clarisse,

 

When you try to deploy a trigger/class to Production all the test classes would run and it should have an overall coverage of 75% without any errors. 

 

All the errors on the first screen (CMSFoldersControllers, etc)...  its respective test classes should be fixed and once fixed make sure you have coverage of 75% by running "Run All Tests".

cjmarchi1cjmarchi1

hi Sam,

These classes you mentioned (CMSFoldersControllers, etc) are all NATIVE classes from my org, they were not created by me!

Here is what I just did: deleted both my trigger and test class (I only built this trigger and test class...so there is nothing left customized by me on Force.com IDE), and ran all tests on all classes.

Still, I get the same coverage problem (42%) with the NATIVE classes that came along with my org config in the Force.com IDE...weird!!!

Any ideas?

:-(

Anu Raj.ax1269Anu Raj.ax1269

Hi

As Sam mention it is due to the other trigger and test class got run when you push to production. You need to find on which condition it get field where the some time it would be such that you need to add some fields to the test class of the other trigger. 

eg: if you are inserting a Account in trg1, trg2, trg3. But conditions for all the trigger will be different so the test class will be created on the bases of the trigger. But when you push to production all the test class related to the inserting Account will get run some get passed some not so. Most it may be because missing of field which is required field the trigger.

Thanks 

Anu

cjmarchi1cjmarchi1

hi guys,

problem solved!!!!

Here is what I just did: uninstalled the CMSForce package from my org (it came along with Salesforce.com), refreshed the salesforce schema on Force.com IDE, and both trigger and test class deployed perfectly to server (100% coverage)....**bleep** CMS package...LOL

 

My trigger had 100% coverage with my test class since the beginning, so the coverage problem was with classes used by this CMSForce package.

 

Thanks for taking your time to help me out.

 

Clarisse

This was selected as the best answer