To add to the existing answer, this situation isn't really any different than testing a trigger. You have three basic aspects you need to verify:
- Action - What happens?
- Filter - Which records are acted on?
- Trigger - Are the above bound to database events?
When you use
Process Builder to invoke
Apex, you only have to
Unit Test the
Action. The other two aspects are configuration and should be tested functionally, not via automated unit testing.
The code does not care if it is bound to any database events, nor which records to act on. That's not its job, and it's not what you should test. The code just cares about what it should be doing with the supplied input, and that is what you should test. It's just like testing any other
Service layer method.
static testMethod void testMyInvocableMethod()
// set up data
//directly invoke method
// assert on behavior