Stochastic dominance rules are well-characterized and widely used. This work aims to describe and better understand the situations when they do not hold by developing measures of stochastic non-dominance. They quantify the error caused by assuming that one random variable dominates another one when it does not. To calculate them, we search for a hypothetical random variable that satisfies the stochastic dominance relationship and is as close to the original one as possible. The Wasserstein distance between the optimal hypothetical random variable and the original one is considered as the measure of stochastic non-dominance. Depending on the conditions imposed on the probability distribution of the hypothetical random variable, we distinguish between general and specific measures of stochastic non-dominance. We derive their exact values for random variables with uniform, normal, and exponential distributions. We present relations to almost first-order stochastic dominance and to tractable almost stochastic dominance. Using monthly returns of twelve assets captured by the German stock index DAX, we solve portfolio optimization problems with the first-order and second-order stochastic dominance constraints. The measures of stochastic non-dominance allow us to compare the optimal portfolios with respect to different orders of stochastic dominance from a new angle. We also defined the closest dominating and closest approximately dominating portfolios. They brought a better understanding of the relationship between the two types of optimal portfolios. Using moving window analysis, the relationship of the in-sample measure of stochastic non-dominance to out-of-sample performance was studied, too.