How can Document folder be created in unit tests?

Can Document folders be created in unit tests? If not, is there a simple workaround for testing Document objects in unit tests?

Answer

Unfortunately most metadata objects, such as Folders, don’t support DML and are only available for programmatic manipulation via the Metadata API which means you’re stuck with the folders already in the org when you run your test.

One approach is create a specific folder for testing and use that in your tests. Alternatively you can query a folder for use in your tests.

Attribution
Source : Link , Question Author : ipavlic , Answer Author : Ralph Callaway

Leave a Comment