I have a section in my notebook devoted to unit testing, since I'm not comfortable to use the built-in system. I'd like to evaluate the entire section by button click. But I get lost in the notebook FrontEnd and what not evaluation and selection controls. All I achieved so far is to create the Button[] (yay!).

In short:

-The section is introduced by the 3rd [Alt+3]-headline
-The entire section group should be evaluated
-The button can pretty much be located anywhere, specifically inside this section, if it makes the code easier

I am aware that I can click the grouping brace at the right and then Shift+Enter, but it requires some maneuvering skills to not misclick and accidentally evaluate only half or the entire notebook.

  • $\begingroup$ Try: Button["Evaluate selected cell", SelectionEvaluate[SelectedNotebook[]]] $\endgroup$ Commented Sep 23, 2020 at 12:40
  • $\begingroup$ I don't want to evaluate the selected cell but the group the selected cell is in $\endgroup$ Commented Sep 23, 2020 at 12:45
  • $\begingroup$ I have button in my notebook toolbar (aka docked cell) that runs all unit tests that reside in a separate .wlt file. This is just a text file with many VerificationTest commands. This way it runs quite fast compared to testing notebooks. $\endgroup$ Commented Nov 14, 2022 at 19:26

1 Answer 1


Does it fit your needs?

It can be anywhere in the notebook with your tests:

 "Run 3rd subchapter's group"
, SelectionMove[
    Cells[CellStyle -> "Subchapter"][[3]]
  , All
  , CellGroup
; SelectionEvaluate @ EvaluationNotebook[]
  • $\begingroup$ Thanks, it's "Chapter", not "Subchapter" in my Notebook (Version 12.1) but otherwise this works fine :) $\endgroup$ Commented Sep 23, 2020 at 12:44
  • $\begingroup$ Does menu Format > Style list "Chapter" next to Alt+3 for you? $\endgroup$
    – Kuba
    Commented Sep 23, 2020 at 12:51
  • $\begingroup$ Yes, that's how I found the correct Identifier. $\endgroup$ Commented Sep 23, 2020 at 12:54

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.