5

When you deploy an inbound change set with apex classes and their respective test classes in the change set, does the validation run tests that are in the change set or those already in the org?

So let’s say for example I am deploying from sandbox v1 to production. Production already has an apex class "class-v1" which has a method say cover() and it's associated test class "test-v2". In sandbox v1, I have an apex class "class-v2" and its associated test class "test-v2". I add "class-v2" and "test-v2" to a change set and upload the change set to production. In production I click validate on the uploaded change set. When the validation runs, does the org look in the change set for "test-v2" or does it run the test that against "test-v1" or a merged version?

1
  • 1
    The test class that you are deploying will be run on validation, otherwise we can never increase test coverage without creating new test class.
    – javanoob
    Commented Apr 14, 2021 at 21:34

1 Answer 1

5

It will run the tests on whatever you are trying to deploy/validate. So in your case, it will validate class-v2 and run tests for your test-v2 class.

4
  • 1
    I don’t think this fully answers what is asked in the question..
    – javanoob
    Commented Apr 14, 2021 at 21:30
  • Can you elaborate on what I missed? Happy to expand on my answer. Commented Apr 15, 2021 at 21:36
  • OP was asking if there is a test class in the org and we are deploying the same test class with changes, which one runs on the deploy? The one already existing in the org or the one we are deploying. Atleast thats what I understood from reading of the question.
    – javanoob
    Commented Apr 15, 2021 at 21:41
  • 1
    If you are deploying changes and it is still running the old version of your tests how can you ever deploy new changes? you will get errors everytime. That's why I answered it will run the tests on whatever you are trying deploy, which IMO addresses OPs question. Commented Mar 15, 2022 at 19:03

You must log in to answer this question.

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