Batch Apex can be tested like any Apex code, although you are limited to a single transaction’s worth of data (one invocation of the
execute method). A batch job started within a test runs synchronously, and does not count against the organization’s limit of five batch jobs.
The class in Listing 9.7 tests the Batch Apex example from Listing 9.1 and achieves 100% test coverage. The annotation
=true) allows the test to access the data in the organization rather than requiring it to create its own test data. Alternatively, you could modify the code to omit the annotation and insert a few Project records to serve as test data.