Next: , Previous: How to Run Tests, Up: How to Run Tests

2.1 Running Tests Interactively

You can run the tests that are currently defined in your Emacs with the command M-x ert RET t RET. (For an explanation of the t argument, see Test Selectors.) ERT will pop up a new buffer, the ERT results buffer, showing the results of the tests run. It looks like this:

     Selector: t
     Passed: 31
     Failed: 2 (2 unexpected)
     Total:  33/33
     
     Started at:   2008-09-11 08:39:25-0700
     Finished.
     Finished at:  2008-09-11 08:39:27-0700
     
     FF...............................
     
     F addition-test
         (ert-test-failed
          ((should
            (=
             (+ 1 2)
             4))
           :form
           (= 3 4)
           :value nil))
     
     F list-test
         (ert-test-failed
          ((should
            (equal
             (list 'a 'b 'c)
             '(a b d)))
           :form
           (equal
            (a b c)
            (a b d))
           :value nil :explanation
           (list-elt 2
                     (different-atoms c d))))

At the top, there is a summary of the results: we ran all tests defined in the current Emacs (Selector: t), 31 of them passed, and 2 failed unexpectedly. See Expected Failures, for an explanation of the term unexpected in this context.

The line of dots and Fs is a progress bar where each character represents one test; it fills while the tests are running. A dot means that the test passed, an F means that it failed. Below the progress bar, ERT shows details about each test that had an unexpected result. In the example above, there are two failures, both due to failed should forms. See Understanding Explanations, for more details.

In the ERT results buffer, TAB and S-TAB cycle between buttons. Each name of a function or macro in this buffer is a button; moving point to it and typing RET jumps to its definition.

Pressing r re-runs the test near point on its own. Pressing d re-runs it with the debugger enabled. . jumps to the definition of the test near point (RET has the same effect if point is on the name of the test). On a failed test, b shows the backtrace of the failure.

l shows the list of should forms executed in the test. If any messages were generated (with the Lisp function message) in a test or any of the code that it invoked, m will show them.

By default, long expressions in the failure details are abbreviated using print-length and print-level. Pressing L while point is on a test failure will increase the limits to show more of the expression.