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
Michael Webb 15Michael Webb 15 

Failure on a test class

Hello All,

We have a test class that is causing errors when I try to move items into production. I know what is causing the error (I am not a developer and we do not have one here) it is the last line that when the developer created the test case would have been null, but since then there was a change. I just need to comment out one line.

I know how to comment out the line, I just don't know how to get that test class back into prod, when I try the test runs and errors out so it is basically a catch22 here. Thanks in advance for any assistance.
Best Answer chosen by Michael Webb 15
Rohit Sharma 66Rohit Sharma 66
In sandbox comment out the line which which causing the error ans save the test class. Now run the test class in sandbox, make sure the test class is passed.
Now create a outbound change set: Deploy --> Outbound change set
In the "Change Set Components" section click on the Add button
Select Apex class from the drop down and select the test class that you modified.
Once done click on upload button and select your production org.
After few minutes login to your Production org and search for Inbound change set.
Open the change set that you have pushed, and click on Deploy button.

Just try and let me know if you find any issues.

All Answers

Sri549Sri549
Hi,
Could you please post the complete error, so that i can help you out.

Regards,
Srinivas Gupta
Michael Webb 15Michael Webb 15
Sure - I believe I know how to fix the error and why it occurred, it will go away if I comment out Line 48. Although I don't know how to get the fixed test class back into production.

Thank you

Error message when validated moving a change set into prod.

SelectEmailTemplate_TestmyUnitTestSystem.AssertException: Assertion Failed 
Stack Trace: Class.SelectEmailTemplate_Test.myUnitTest: line 48, column 1
Rohit Sharma 66Rohit Sharma 66
In sandbox comment out the line which which causing the error ans save the test class. Now run the test class in sandbox, make sure the test class is passed.
Now create a outbound change set: Deploy --> Outbound change set
In the "Change Set Components" section click on the Add button
Select Apex class from the drop down and select the test class that you modified.
Once done click on upload button and select your production org.
After few minutes login to your Production org and search for Inbound change set.
Open the change set that you have pushed, and click on Deploy button.

Just try and let me know if you find any issues.
This was selected as the best answer
Michael Webb 15Michael Webb 15
The problem is that the test class is in Production when I try to move the test class from sandbox to production it runs the tests so I can’t move that one into prod. Thanks!
Rohit Sharma 66Rohit Sharma 66
It will run the updated test class, not the one that exist in production. Please try.
Michael Webb 15Michael Webb 15
Thank you it worked!
Rohit Sharma 66Rohit Sharma 66
Thanks. Can you please mak that one as the best answer.