1. The terminal investment hypothesis predicts that as an organism's prospects for survival decrease, through age or when exposed to a pathogenic infection, it will invest more in reproduction, which should trade-off against somatic maintenance (including immunity) and therefore future survival. Attempts to test this hypothesis have produced mixed results, which, in addition, mainly rely on the assessment of changes in reproductive effort and often overlooking its impact on somatic defences and survival. Alternatively, animals may restrain current reproduction to sustain somatic protection, increasing the chance of surviving for additional reproductive opportunities.2. We tested both of these hypotheses in females of the yellow mealworm beetle, Tenebrio molitor, an iteroparous insect with reproductive tactics similar to that of long-lived organisms.3. To achieve this, we mimicked pathogenic bacterial infections early or late in the life of breeding females by injecting them with a suspension of inactivated Bacillus cereus, a known natural pathogen of T. molitor, and measured female age-specific fecundity, survival, body mass and immunity.4. Inconsistent with a terminal investment, females given either an early or late-life immune challenge did not exhibit reduced survival or enhance their reproductive output. Female fecundity declined with age and was reduced by the early but not the late immune challenge. Both early and late-life fecundity correlated positively with life expectancy. Finally, young and old females exhibited similar antibacterial immune responses, suggesting that they both restrained reproduction to sustain immunity. 5. Our results clearly demonstrate that age-specific reproduction of T. molitor females under pathogenic threat is inconsistent with a terminal investment. In contrast, our results instead suggest that females used a reproductive restraint strategy to sustain immunity and therefore subsequent reproductive opportunities. However, as infections were mimicked only, the fitness benefit of this reproductive restraint could not be shown.