We study a stopping problem arising from a sequential testing of two simple hypotheses H₀ and H₁ on the drift rate of a Brownian motion. We impose an expectation constraint on the stopping rules allowed and show that an optimal stopping rule satisfying the constraint can be found among the rules of the following type: stop if the posterior probability for H₁ attains a given lower or upper barrier; or stop if the posterior probability comes back to a fixed intermediate point after a sufficiently large excursion. Stopping at the intermediate point means that the testing is abandoned without accepting H₀ or H₁. In contrast to the unconstrained case, optimal stopping rules, in general, cannot be found among interval exit times. Thus, optimal stopping rules in the constrained case qualitatively differ from optimal rules in the unconstrained case.