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
Alx MrAlx Mr 

How to deploy Test Class itself

I have a new test class that covers the apex controller code, all in sandboxe. I have old test class and old apex controllers. when i deploy new test class i get an error: method doesn't exist in the controller (of course it doesn't because it is an old controller. When i deploy apex controller the test coverage does not pass.
Question how to deploy/update the test class in production?
Thank you.
Best Answer chosen by Alx Mr
Temoc MunozTemoc Munoz
I see.

You need to deploy both the test class and the apex controller class. In your case, you can't just deploy the test class. Salesforce will run test locally (i.e. in your current org/package).

Create a package with both files and try to deploy.
 

All Answers

Temoc MunozTemoc Munoz
Hi Alx.

I'm not sure what the actual error is, and I'm not sure why the new test class is not updated to reflect the new apex controller.

In any case, if you have Eclipse IDE:

1. Download Production instance to Eclipse
2. Select the test class you want to modify
3. Save the class. This will save it locally as you can't modify code in Production.
4. Right click on the class and select Deploy to Server
5. Follow the instructions and you should be good to go (as long as you don't have any more issues with your org).

Thanks

Temo
Alx MrAlx Mr
Thank you Temoc.
I want to deploy new apex class. For this i need my class to pass the code coverage test during deployment.
old production test class doesn't cover the controller class. for this i wrote new testclass. The new test class cannot be deployed as it tests methods that doesn't exist in old controller class. So the fail happens as the method referenced/tested in test class doesn't exist in old controller class.
I need to import/deploy it somehow into production as i cannot modify the old test class which is in active org.
Please help me :)
Temoc MunozTemoc Munoz
I see.

You need to deploy both the test class and the apex controller class. In your case, you can't just deploy the test class. Salesforce will run test locally (i.e. in your current org/package).

Create a package with both files and try to deploy.
 
This was selected as the best answer
Alx MrAlx Mr
Thank you, Temoc. when i covered the apex controller code by testclass at max possible (90%) the deployment went smoothly. i think in my preliminary tries the coverage was not quite sufficient even if the initial approximate calculation was 76%. 
Temoc MunozTemoc Munoz
Nice job man!