0

In a visual flow that is autolaunched on Opportunity creation. In it I have a lookup element to a custom setting that returns a string based on a date value.

When I run this in the UI and create an Opp everything works fine, but when I create an Opp while running an apex test class the custom setting lookup always returns null. Is there a reason this doesn't work in an apex test class or it is just a bug?

Another answer suggested rebuilding the custom settings records, which I did with no luck.

  • 1
    hierarchical or list custom setting? – cropredy Jun 14 '18 at 0:00
3

Custom Settings are treated as data, not metadata, in test context, and as such are not visible during the test run.

If you need that setting available during the course of your unit test (in Apex or Flow), the test or its associated @testSetup method needs to create and insert the Custom Setting value.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.