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
JoeZaloom.ax395JoeZaloom.ax395 

Test Coverage 72% in IDE, 0% using Migration Tool

Hello,

I thought I'd seen reference to this in previous posts, but I can't seem to find any thing when I search.

When I run all tests in the SF web interface, I get 72% test coverage. When I attempt to deploy with the migration tool, I get a message like this:

Test coverage of selected Apex Trigger is 0%, at least 1% test coverage is required

After running the test In the web interface, I see the test methods for both triggers listed under Test Success, and I can see debug output from the triggers in the test log.

Is there some xml I need to add to build.xml to specify the test methods for triggers? Maybe I'm doing something else wrong?

Here is one of the trigger test methods:

Code:
public class TestTriggers {

 public static testMethod void testChatTrigger()
 {

  isp__Chat__c chat = new isp__Chat__c(); //isp__email__c='fred@bedrock.gov');
  
  chat.isp__email__c  ='fred@bedrock.gov';
  chat.isp__Last_Name__c = 'Flinstone';
  chat.isp__first_name__c = 'Fred';
  chat.isp__phone__c  = '99955512121';
  
  // get Account, Contact to set chat references
  Account[] aa = [select id from Account];  
  if (aa.size() > 0)
  {
   chat.isp__account__c = aa[0].id;
  }
  
  Contact[] cc = [select id, account.id from Contact];  
  if (cc.size() > 0)
  {
   chat.isp__contact__c = cc[0].id;
  }
  
  insert chat;
  
  System.debug('NEW CHAT ID= ' + chat.id);
System.assert(chat.id != null);

  } }

Thanks.
joe

JonPJonP
What files are in your deploy folder?  Are you deploying both the trigger and the test class at the same time?

JoeZaloom.ax395JoeZaloom.ax395
Yes, deploying a VF page, custom controller, two helper classed, two trigers, and two test classes.
JonPJonP
What happens when, rather than using Run All Tests, you just Run Tests for the test class you posted above?

Also, what does your package.xml file look like?
JoeZaloom.ax395JoeZaloom.ax395
When I run tests for the TestTriggers class I get:

Tests Run: 2
Test Failures: 0
Code Coverage: 93

Under Test Success I see both testChatTrigger() and testMailTrigger()

No errors in debug log.

package.xml:
Code:
<—xml version="1.0" encoding="UTF-8"–>
<Package xmlns="http://soap.sforce.com/2006/04/metadata">

    <types>
        <members>*</members>
        <name>ApexClass</name>
    </types>


    <types>
        <members>*</members>
        <name>ApexPage</name>
    </types>
    
    <types>
        <members>*</members>
        <name>ApexTrigger</name>
    </types>
    
    <version>12.0</version>
    
</Package>

 Thanks for the reply

JoeZaloom.ax395JoeZaloom.ax395
I'm still experiencing this problem with the migration tool. I found and fixed one problem: I didn't have all classes w/ test methods listed in <runtest> tags in within the "deployCode" target in build.xml. After I entered the missing classes I get 80% code coverage in the SF web UI. When I run the deployment tool against a clean dev org it succeeds.

When I run the migration tool with the same code against an existing client's org that has installed packages, the migration tool reports 42% code coverage. I get the same result using the Eclipse Force.com deployment tool. In Eclipse, under the "Code Coverage Results" I can see classes of the installed package listed as having very little code coverage.

So, my question is: how do I deploy an application without having to test all code in installed packages?

Thanks.