In this chapter, we present a unified theory of hypothesis testing based on ranks. The theory consists of defining two sets of ranks, one consistent with the alternative and the other consistent with the data itself in a notion to be described. The test statistic is then constructed by measuring the distance between the two sets. Critchlow (1986, 1992) utilized a different definition for measuring the distance between sets. The problem can embedded into a smooth parametric alternative framework which then leads to a test statistic. It is seen that the locally most powerful tests can be obtained from this construction. We illustrate the approach in the cases of testing for ordered as well as unordered multi-sample location problems. In addition, we also consider dispersion alternatives. The tests are derived in the case of the Spearman and the Hamming distance functions. The latter were chosen to exemplify that different approaches may be needed to obtain the asymptotic distributions under the hypotheses.