In this study, the complicated reasoning and processes inherent in diagnostic testing were analyzed, and a mathematical theory was developed for effectively stopping the transmission of infection in the context of coronavirus disease 2019 (COVID-19). As a result of this work, a new formula was developed for the “boundary condition for contagion containment,” which, based on a horizontal transmission model, gives the lower limit of sensitivity for a diagnostic test to stop the virus spreading. Two parameters are considered in the model: the level of transmission and the effective reproduction number. In example computations, the formula indicated that a one-off polymerase chain reaction-based test with a sensitivity of 85% would not be sufficient to contain highly contagious infections such as the Delta variant of SARS-CoV-2, which would likely require a sensitivity close to 100% for its containment. Furthermore, a cascade judgment system for multiple tests was proposed and examined as a form of triplet test system. This approach can enhance the accuracy of COVID-19 testing up to the minimum level needed to stop the virus spreading. The theory developed in this study will not only contribute as an academic exercise, but also be useful for making evidence-based decisions on public policy for pandemic control.