Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Code Coverage Error deploying CampaignMember Trigger (in production) #74

Closed
greuter opened this issue Oct 5, 2014 · 9 comments
Closed

Comments

@greuter
Copy link

greuter commented Oct 5, 2014

Hi Andrew,
I am attempting to create a rollup summary between the CampaignMember and Contact objects. When I use the Manage Child Button to create the trigger/test class, I do not receive an error, but the trigger/test class are not created.
deploy_complete

If I go to deployment status I see that there is a code coverage error on deploying the trigger:
code_coverage

I have successfully been able to deploy triggers using the manage child button for other relationships (various child objects of contact), so it seems like this is something specific to the CampaignMember/contact relationship. However, I tested deploying the same trigger in my sandbox, and was successful. (This sandbox was just refreshed, so it has the same apex code/fields/validations as my production). All of my own namespace tests are passing without a problem in both production and sandbox. Any ideas about what is going wrong?

Some stuff I've tried:

  • Uninstalled dlrs completely, and reinstalled - same issue is remaining.
  • Deploying the CampaignMember Trigger/Test successfully created by dlrs in my sandbox to production using change sets (also failed because of code coverage...interestingly, when I run the automatically created test, the trigger does not show code coverage. This is despite successfully deploying in the sandbox on creation.)
  • Manually creating a trigger/test class in my sandbox that matches the dlrs format, and then attempting to deploy to production through change sets. Same code coverage problem when deploying to production.

I am puzzled by why this would only occur on this one object and only in production. The only thing that I can think of is that this was the first trigger that I attempted to deploy using the Manage Child Button in production. When I first did that, I did find that I had an apex test in production that needed to be updated. I fixed that (in both production and sandbox), and that test is now running without a problem.

Seems like this could be related to #54 or #7, but I wasn't sure.

Thank you for making a truly awesome tool!

@afawcett
Copy link
Collaborator

So sorry for not getting back sooner, lead up to Dreamforce has been crazy! So i "think" this is related to 54 as you say, i need to add some code coverage reporting handling here. The reason it deploys in Sandbox is code coverage is not enforced in Sandbox during deployment.

The test code must successfully insert a record to get coverage, as you can see it doesn't set any field values on CampaignMember so i'm thinking that might be the reason, i'll do some testing myself. In the meantime, you might want to try enabling the Debug Logs when you do the deploy to see if you can see if any error is being thrown by the test.

@afawcett
Copy link
Collaborator

I've done some testing and the DLRS trigger is being executed even when an empty CampaignMember is being inserted, i think what i will do is add the code coverage reporting code anyway, and include that in the next release, then you can try again. Let me know if you see anything from the debug logs in the meantime.

@afawcett
Copy link
Collaborator

Also can you check the number of Triggers you have on CampaignMember please?

@afawcett
Copy link
Collaborator

I've just uploaded v1.11 (not updated main page yet) and have to go to catch a flight, but wanted to pass it on here for you to try, see what additional information this might give us now that I've added some extra reporting in.

@csSimonMolloy
Copy link

We hit a similar problem with two other triggers : dlrs_pse_Timecard_HeaderTrigger and dlrs_pse_AssignmentTrigger. Running the Apex tests in our live environment showed that they were 100% covered, but when trying to deploy, we were told that both of these had 0% code coverage. We ended up just writing our own test code to make sure each trigger was covered, and this allowed us to deploy. We had to do this as a deployment was needed quite urgently, but now we've managed to deploy the code I'll be interested to see what the actual issue may have been.

@afawcett
Copy link
Collaborator

Thanks @csSimonMolloy, when you say "We ended up just writing our own test code to make sure each trigger was covered", how did this differ from the auto generated test code, can you elaborate?

I'm also, thinking this is some kind of Winter'15 release issue, given the timing of other reports today and last week.

@greuter
Copy link
Author

greuter commented Oct 20, 2014

Thanks for continuing to dig into this Andrew. I went ahead and installed v1.11, and did get the deploy page to show the coverage error, but no new information. See screenshot below.

code_coverage_error

There is one existing trigger on the campaign member, which comes bundled with the non profit starter pack. Not sure if you're familiar with that code, but it is posted on github:

https://github.com/SalesforceFoundation/Relationships/blob/master/src/triggers/RelationshipCampaignMembers.trigger

If you think that's the conflict, there is a custom setting that allows me to toggle that trigger off. I could toggle it off, and try deploying the dlrs trigger. (I might need to check the documentation on the npsp trigger - I don't think toggling it on and off will be too much of a problem, but I'm not sure.)

@csSimonMolloy
Copy link

Hi Andrew,

That's the strange thing. Even though the test classes for the two triggers that were reporting 0% coverage are there, we were still getting the 0% coverage problem on those two triggers.
We have written some of our own functionality around triggers etc. so in the test classes for that we made sure we included code to call the two triggers we were having problems with - and this resolved the issue.

Simon

@afawcett
Copy link
Collaborator

afawcett commented Nov 1, 2014

Most odd indeed. I did get two others folks ask me during this week about this type of issue, but none since. Makes me wonder if it was a platform glitch?

BTW, one thing i should probably promote more is the Developer API for the tool, if you have your own triggers, you can call a method on the RollupService and avoid the extract triggers.

@afawcett afawcett closed this as completed Nov 1, 2014
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

3 participants