We study the problem of testing composite hypotheses versus composite alternatives, using a convex duality approach. In contrast to classical results obtained by Krafft and Witting (Z. Wahrsch. Verw. Gebiete 7 (1967) 289–302), where sufficient optimality conditions are derived via Lagrange duality, we obtain necessary and sufficient optimality conditions via Fenchel duality under compactness assumptions. This approach also differs from the methodology developed in Cvitanic ́ and Karatzas (Bernoulli 7 (2001) 79–97).