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
Jordan VasquezJordan Vasquez 

SOQL Query fails in Apex Test during deployment but passes when manually run?

Hello everyone,

All of a sudden I have been experiencing an issue with one of my apex test classes, mainly for a single line of code. This test class has been working for months but all of a sudden has prevented me from pushing anything into my Production org. Furthermore, it is failing on a SOQL query that I know should pass. I can make this same exact query in workbench and get results. Running the same test manually in my Production Org passes. Running all tests in my Production Org at once and everything passes.

I am at a loss for what is happening and any guidance is greatly appreciated, thanks.
 
Jordan VasquezJordan Vasquez
This is the query that is attempting to run in my org: AssetRC = [select id,name from recordtype where sobjecttype = 'Asset' and name = 'System'];

This passes in my test case when run manually but fails when I attempt to deploy anything, even a simple comment update in my test case!
v varaprasadv varaprasad
Hi Jordan,

Please check once in your deployment org is having record type(System) or not.

AssetRC = [select id,name from recordtype where sobjecttype = 'Asset' and name = 'System'];

If not create or deploy the first record type then Deploy your code.

Hope this helps you!

Thanks
Varaprasad
@For Support: varaprasad4sfdc@gmail.com
 
v varaprasadv varaprasad
Means Target org.