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
debradebra 

Apex tests produce different results change set vs manual execution?

I am wondering if anyone has noticed different test results when running Apex tests manually via Apex Test area vs. running local tests during change set validation/deployment.

I have one test class with some failing tests when run during change set validation but the test all pass when run manually.

In order to isolate the issue I created a simple change set with just one existing custom field in the change set and when I did deployment validation ran local tests and see that my one Apex class had a subset of tests fail but the same tests pass if I run the Test Class tests manually.  

This test class has not been modified for quite some time originally written by a contractor and I do not see any issues with the test code.

Any tips on how to troubleshoot/fix this type of issue - I'm really stuck as I have some Apex code I want to deploy to production but am unable to do so due to this testclass issue.

Thanks
Debra
 
Best Answer chosen by debra
debradebra
Updated the class so that the test data setup method was no longer configured as a @testsetup method
Before (failing):  @testsetup     static void setupData()
After (Passed)  static void SetupData() - then called in each test method.

Not sure why this resolved the issue - doesn't really make sense to me but something about the @testsetup method caused deployment validation to fail on a subset of tests in this test class.