Plant chemodiversity, the diversity of plant specialized metabolites, is an important dimension of biodiversity. However, there are so far few quantitative models to test verbal hypotheses on how chemodiversity evolved. Here we develop such a model to test predictions of five hypotheses: the "fluctuating selection hypothesis", the "dominance reversal hypothesis", the interaction diversity hypothesis, the synergy hypothesis, and the screening hypothesis. We build a population genetic model of a plant population attacked by herbivore species whose occurrence fluctuates over time. We study the model using mathematical analysis and individual-based simulations. As predicted by the "dominance reversal hypothesis", chemodiversity can be maintained if alleles conferring a defense metabolite are dominant with respect to the benefits, but recessive with respect to costs. However, even smaller changes in dominance can maintain polymorphism. Moreover, our results underpin and elaborate predictions of the synergy and interaction diversity hypotheses, and, to the extent that our model can address it, the screening hypotheses. By contrast, we found only partial support for the "fluctuating selection hypothesis". In summary, we have developed a flexible model and tested various verbal models for the evolution of chemodiversity. Next, more mechanistic models are needed that explicitly consider the organization of metabolic pathways.