We study optimal testing to inform quarantine decisions for a population exhibiting a heterogeneous probability of carrying a pathogen. Because test supply is limited, the planner may choose to test a pooled sample, which contains the specimens of multiple individuals (Dorfman, 1943). We characterize the unique optimal allocation of tests. This allocation features assortative batching, whereby agents of differing infection risk are never jointly tested. Moreover, the planner tests only individuals whose prior quarantine decision is the most uncertain. Finally, individuals with higher infection risk are tested in smaller batches, because such tests minimize the informational externality of group testing.