       ;; Yuck!  More messing around with Edebug internals.
       (dolist (data edebug-form-data)
         (let* ((name (edebug--form-data-name data))
-               (frequencies (get name 'edebug-freq-count))
+               (ours (eq (get name 'edebug-behavior) 'elisp/ert/coverage))
+               (frequencies
+                (get name (if ours 'elisp/ert/frequencies 'edebug-freq-count)))
                ;; We don’t really know the number of function calls,
                ;; so assume it’s the same as the hit count of the
                ;; first breakpoint.

                   ;; closing parenthesis or space.  We don’t consider this a
                   ;; covered line since it typically only contains unimportant
                   ;; pieces of the form.
                   (unless (memql (char-syntax (char-after position))
                                  '(?\) ?\s))
                     (let ((line (line-number-at-pos position)))
                       (cl-callf max (gethash line lines 0) freq))))
          (push (list (line-number-at-pos begin)

  "Test source files to be loaded.
This list is populated by --test-source command-line options.")

;; Customizable Edebug behavior only appeared in Emacs 27.
(defvar edebug-behavior-alist)
(defvar edebug-after-instrumentation-function)
(defvar edebug-new-definition-function)

(defun elisp/ert/run-batch-and-exit ()
  "Run ERT tests in batch mode.
This is similar to ‘ert-run-tests-batch-and-exit’, but uses the
