When designing a herd-level prevalence study that will use an imperfect diagnostic test, it is necessary to consider the test sensitivity and specificity. A new approach was developed to take into account the imperfections of the test. We present an adapted formula that, when combined with an existing piece of software, allows improved planning. Bovine paratuberculosis is included as an example infection because it originally stimulated the work. Examples are provided of the trade-off between the benefit (low number of herds) and the disadvantage (large number of animals per herd and exclusion of small herds) that are associated with achieving high herd-level sensitivity and specificity. We demonstrate the bias in the estimate of prevalence and the underestimate of the confidence range that would arise if we did not account for test sensitivity and specificity.