Testing (having students recall material) and worked examples (having students study a completed problem) are both recommended as effective methods for improving learning. The two strategies rely on different underlying cognitive processes and thus may strengthen different types of learning in different ways. Across three experiments, we examine the efficacy of retrieval practice and worked examples for different learning goals and identify the factors that determine when each strategy is more effective. The optimal learning strategy depends on both the kind of knowledge being learned (stable facts vs. flexible procedures) and the learning processes involved (schema induction vs. memory and fluency building). When students’ goal was to remember the text of a worked example, repeated testing was more effective than repeated studying after a 1-week delay. However, when students’ goal was to learn a novel math procedure, the optimal learning strategy depended on the retention interval and nature of the materials. When long-term retention was not crucial (i.e., on an immediate test), repeated studying was more optimal than repeated testing, regardless of the nature of materials. When long-term retention was crucial (i.e., on a 1-week delayed test), repeated testing was as effective as repeated studying with nonidentical learning problems (that may enhance schema induction), but more effective than repeated studying with identical learning problems (that may enhance fluency building). Testing and worked examples are both effective ways to learn flexible procedures, but they do so through different mechanisms. (PsycINFO Database Record (c) 2018 APA, all rights reserved)