+ Start a Discussion
SFDCDevQASFDCDevQA 

Trigger has code coverage in Sandbox but says it has none when trying to deploy to production

I have a trigger that I had deactivated while changing some other nonrelated apex classes and now when I went back to activate the trigger I am getting an error saying that there is 0% test coverage on the trigger and therefore I cannot deploy.  However in the Sandbox it shows that I have 91% test coverage on the trigger.  I've tried deploying the test classes first and was able to do that but am still unable to deploy the activated trigger.  It insists that there is no coverage for the trigger in production while having 91% coverage in the Sandbox.  Has anyone else run into this issue before?  Can anyone tell me why it would be doing this? 

Thanks,

Amanda

MarkWaddleMarkWaddle

I have not had a problem like this before. Is it possible that the test coverage is dependent on some data that is only in the sandbox and not production?

 

If you can post the code that would help.

 

Regards,

Mark

dotnet developedotnet develope

Hi

 

have you used any static values in test class for code coverage?

 

if yes, you need to rework on test class.

 

 

 

hgarghgarg

Probably in test class you are working on existing sandbox data, when you deploy the test class to production that data would not exist, to make it successfull you should create test data in the test class itself. hope it is clear.

Afzal MohammadAfzal Mohammad

This may happen if you have hardcoded values in your test cases. Test cases with hardcoded values may have different code coverage percentage in different environments.

 

To fully understand your issue, I suggest you post your code.

 

Afzal