To use a stub version of an Apex class:
1. Define the behavior of the stub class by implementing the System. StubProvider interface.
2. Instantiate a stub object by using the System. Test. createStub() method.
3. Invoke the relevant method of the stub object from within a test class.