Timeline for How to test a static void @HTTP method that creates custom metadata
Current License: CC BY-SA 4.0
7 events
when toggle format | what | by | license | comment | |
---|---|---|---|---|---|
Dec 17, 2019 at 0:36 | vote | accept | number41 | ||
Oct 1, 2019 at 23:29 | answer | added | number41 | timeline score: 0 | |
Sep 26, 2019 at 21:17 | comment | added | cropredy | N.B. I use andyinthecloud Custom Metadata Services package to deploy MDT. It has its own mocking support so you can assert you called it with proper args. As a package, it is fully tested. | |
Sep 26, 2019 at 21:14 | comment | added | David Reed | Both comments could be fine answers, Roti & Phil! | |
Sep 26, 2019 at 19:53 | comment | added | Roti | Another option would be to declare the variables as static variable defined at the class level (ie DegOff and DocContainer) or copy their contents in the function to class member static variables that are set as @TestVisible (so other classes aren't modifying or viewing it). Then you can just access the class variable from the test method. That should work in theory. | |
Sep 26, 2019 at 19:38 | comment | added | Phil W | Surely just factor out the method content into a separate non-static method that returns a value you need then write the @HTTP static method to instantiate the class, call the method and do whatever it needs with the returned data then test the non-static method to get most of your required coverage...? Or am I missing something? | |
Sep 26, 2019 at 19:33 | history | asked | number41 | CC BY-SA 4.0 |