The sucrose preference test (SPT) measures the relative preference of sucrose over water to assess hedonic behaviors in rodents. Yet, it remains uncertain to what extent the SPT reflects other behavioral components, such as learning, memory, motivation, and choice. Here, we conducted an experimental and computational decomposition of mouse behavior in the SPT and discovered previously unrecognized behavioral subcomponents associated with changes in sucrose preference. We show that acute and chronic stress have sex-dependent effects on sucrose preference, but anhedonia was observed only in response to chronic stress in male mice. Additionally, reduced sucrose preference induced by optogenetics is not always indicative of anhedonia but can also reflect learning deficits. Even small variations in experimental conditions influence behavior, task outcome and interpretation. Thus, an ostensibly simple behavioral task can entail high levels of complexity, demonstrating the need for careful dissection of behavior into its subcomponents when studying the underlying neurobiology.