We study the design of stress tests that provide information about aggregate and idiosyncratic risk in banks’ portfolios and impose contingent capital requirements. In the optimal static test, an adverse scenario fails all weak and some strong banks, limiting the stigma of failure. Sequential tests outperform static tests. Under natural conditions, the optimal sequential test consists of a precautionary recapitalization, followed by a scenario that fails only weak banks, similar to TARP in 2008, followed by SCAP in 2009. Our results also shed light on the Federal Reserve’s decision to test the banks twice in 2020 during the COVID-19 pandemic.