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
Steve_EarlySteve_Early 

Inline Account Hierarchy not passing tests for code coverage

We have the Inline Account Hierarchy app from Salesforce labs installed. It has been installed and working fine since July 2014 and I've made several Change Set deployments since them without incident. I am now suddenly unable to deploy a Flow from our Sandbox to Production, and this application is the one that is failing the code tests. (I don't have a lot of Apex in the system, (I'm not a programmer) and what Apex I do have is all from 3rd party AppExchange apps like this one.) My code coverage has suddenly gone from something like 89% to 29%. on the AccountStructure class 0 out of 133 lines are passing, and other Classes related to this application are getting 41%, 71% and 84% coverage which is all a bit disturbing.

I haven't altered the test scripts since they were installed.
I have turned off the two validation rules that were running against the account object.
I have added a couple of new custom account fields, but they do not have validation statements in them.
I have added one rollup field recently that counts the number of opportunities on the account. 

Since I have no experience in writing test cases, and have never had to deal with code coverage issues before:

Are there other things I should check?
Are there resources I can reference to learn more?
Does anyone have any ideas on how to fix this?

I don't want to have to delete the application because one of our business units relies on it, but it may come to that if I can't deploy things to production!

Specific errors I encounter are:

Class.InlineAcountHerachy_TestUtilities.updateAccountList: line 106, column 1
Class.AccountHierarchyTestData.createTestHierarchy: line 33, column 1
Class.testAccountHierarchy.testAccountHierarchy: line 6, column 1

First error code near error "106, column 1"
101       if ( this.checkObjectCrud('Account', fieldsToCheck, 'create') && !this.testAccList.isEmpty() ){
102         try{
103           update this.testAccList;
104         }
105         catch( Exception ex ){
106          System.assert( false ,'Pre deploy test failed, This may be because of custom validation rules in your Org. You can check ignore apex errors or temporarily deactivate your validation rules for Accounts and try again.');
107        }
108       }
109       else{
110         System.Assert(false , 'You need right over Account Object');
111       }

Second error at line 33, column 1

26         // Create 10 sub accounts
27       testUtils.createAccounts( 10 , fieldsToCheck );
28       Integer i = 0;
29         for ( Account accAux : testUtils.testAccList ){ //Now i need change the names
30           accAux.Name = 'HierarchyTest' + String.valueOf( i );
31             i++;
32         }
33         testUtils.updateAccountList( fieldsToCheck );        
34         
35         List<Account> accountList = [ Select Id, parentID, name from account where name like 'HierarchyTest%' ORDER BY Name limit 10 ];
36                 
37         for ( Integer x = 0; x < accountList.size(); x++ ){
38             if ( accountList[x].name != 'HierarchyTest0' ){
39                 accountList[x].parentID = parentID;
40                 parentID = accountList[x].Id; 
41             }

Last error at line 6, column 1
1 @isTest
2 private class testAccountHierarchy{
3
4     static testMethod void testAccountHierarchy(){
5
6         AccountHierarchyTestData.createTestHierarchy();
7
8         Account topAccount      = [ Select id, name from account where name = 'HierarchyTest0' limit 1 ];
9         Account middleAccount   = [ Select id, parentID, name from account where name = 'HierarchyTest4' limit 1 ];
10         Account bottomAccount   = [ Select id, parentID, name from account where name = 'HierarchyTest9' limit 1 ];
11         Account[] accountList   = [ Select id, parentID, name from account where name like 'HierarchyTest%' ];
12
13         test.startTest();

Any guidance will be greatly appreciated.
 
Best Answer chosen by Steve_Early
Steve_EarlySteve_Early
This issue is resolved (sort of).

I started looking for changes and differences between the sandbox and production. My sandbox coverage was 90%, and it was 29% in production. The Inline Account Hierarchy application from Salesforce Labs was what was making it fail. I was getting 0% coverage on one Apex Class. 

The one difference that I noticed was that since Spring '15 came out, I activated the new Data.com deduplication features. On a hunch, I deactivated all of the matching and deduplication rules I had in effect, and voila. My production environment went back up to 90%. So I'm not sure if this is an issue with the new feature, or if I did something wrong in setting up the matching rules. 

I will attempt to re-do the matching rules and re-activate all this stuff. If my code coverage drops, I will just have to deactivate it whenever I have a need to deploy something and turn it back on afterwards. I had filed a case with Salesforce to help me resolve this and they are aware of the final outcome. 

All Answers

Steve_EarlySteve_Early
This issue is resolved (sort of).

I started looking for changes and differences between the sandbox and production. My sandbox coverage was 90%, and it was 29% in production. The Inline Account Hierarchy application from Salesforce Labs was what was making it fail. I was getting 0% coverage on one Apex Class. 

The one difference that I noticed was that since Spring '15 came out, I activated the new Data.com deduplication features. On a hunch, I deactivated all of the matching and deduplication rules I had in effect, and voila. My production environment went back up to 90%. So I'm not sure if this is an issue with the new feature, or if I did something wrong in setting up the matching rules. 

I will attempt to re-do the matching rules and re-activate all this stuff. If my code coverage drops, I will just have to deactivate it whenever I have a need to deploy something and turn it back on afterwards. I had filed a case with Salesforce to help me resolve this and they are aware of the final outcome. 
This was selected as the best answer
Edgars Everts 5Edgars Everts 5
Have noticed the same issue in the following places:
https://www.reddit.com/r/SalesforceDeveloper/comments/4rhpmu/warning_while_deploying_the_app/
and in comments on Github space
https://github.com/ForceDotComLabs/Inline-Account-Hierarchy/issues/3

"Hello, When i try to deploy the component "Inline-Account-Hierarchy" from dev sandbox to test sandbox, i get this warning in the component "AccountHierarchyTree" : Warning: (The element type "div" should be terminated by the matching end-tag "</div>" in c__accounthierarchytree at line **) "

Have tried to separate classes and vf page from component, but as they have reference to another, I could not deploy them seperately.
AccountHierarchyTree component left with API = 15, so "invalid" </div> tag work just fine in DEV environment, Account hierarchy is shown on Account detail page.

But not sure if this component can be deployed into test environment!? Any idea, advise would be great!!!
Thank you in advance.