Timeline for Creating a Test Class for 2 Classes [duplicate]
Current License: CC BY-SA 4.0
6 events
when toggle format | what | by | license | comment | |
---|---|---|---|---|---|
Jan 3, 2021 at 20:56 | comment | added | Liam Heppenstall | Thanks Derek! :) | |
Jan 3, 2021 at 20:04 | comment | added | Derek F | salesforce.stackexchange.com/questions/244797/… will also be useful here, though if you're not familiar with unit testing, the marked duplicate will be the one to start with. | |
Jan 3, 2021 at 20:03 | comment | added | Derek F |
The question I've marked this as a duplicate of goes over the basics and provides some resources. Generally speaking, you'll want to create separate test classes for each class. With what you have, that's not entirely possible. Ideally, you'd want to have RunTerritoryRules implement an interface, and have a constructor or method that allows you to set an instance of RunTerritoryRulesCallout to use (a principle called dependency injection) so that you can write a test that says "hey, I know you'd normally run thingX. In this test though, run this other thing, ThingY that I have prep'd).
|
|
Jan 3, 2021 at 20:02 | history | duplicates list edited | David Reed | duplicates list edited from How do I write an Apex unit test? to How do I write an Apex unit test?, How do I unit test code that includes a callout? | |
Jan 3, 2021 at 19:59 | history | closed | Derek F apex Users with the apex badge or a synonym can single-handedly close apex questions as duplicates and reopen them as needed. | Duplicate of How do I write an Apex unit test? | |
Jan 3, 2021 at 19:52 | history | asked | Liam Heppenstall | CC BY-SA 4.0 |