0

So I wrote an Apex trigger in our Sandbox and I keep getting an error saying that my trigger has 0% coverage when I try to deploy it in production using change sets. I don't fully understand what this means or how to fix it. I tried writing a test class in the sandbox as well and the trigger says it's 85% covered so I don't really know what to do from here. Any help is appreciated.

Thanks!

1 Answer 1

2

You need to deploy both the trigger and its unit test in the change set. During deployment, the test will run to ensure that the trigger works as expected.

4
  • I tried doing that, but I still get the same error. When it asks me to "Choose a Test Option" should I be entering the name of the test that I'm deploying using the "Run Specified Test" option?
    – ad_rey
    Commented Mar 7, 2018 at 20:53
  • @ad_rey Unless this trigger lives in complete isolation, you may need to choose to "run all tests." When using Run Specified Tests, every unit (class and trigger) that is called at all needs 75% independently.
    – sfdcfox
    Commented Mar 7, 2018 at 20:55
  • Oh okay. I just tried doing that as well, and some other tests on unrelated objects are causing it to fail.
    – ad_rey
    Commented Mar 7, 2018 at 21:35
  • @ad_rey You'll want to consider fixing them. I realize it's a pain, but failing tests are usually an indication that something is amiss.
    – sfdcfox
    Commented Mar 7, 2018 at 21:43

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .