You need to enable JavaScript to run this app.
优惠活动
大模型
产品
解决方案
定价
更多

使用CLI运行Midje时为何不报告测试成功?

Fix: Midje Doesn't Print Success Summary with Clojure tools.deps

I’ve run into this exact issue before—here’s what’s going on and how to fix it: the problem comes from running tests via a custom -main function, which skips Midje’s built-in logic for generating test summaries. Here are two straightforward solutions:

Instead of executing your -main function, let Midje handle test execution end-to-end. Update your test command to use Midje’s dedicated runner module:

clj -A:test -m midje.run hello.test

This will automatically discover your tests, run all checks, and output the full summary—including the expected All checks (1) succeeded. message when tests pass, and detailed failure reports when they fail.

Solution 2: Manually Trigger the Summary in Your -main

If you want to keep using your custom -main function, you need to explicitly tell Midje to print the final test summary after running your facts. Update your test/hello/test.clj file like this:

(ns hello.test 
  (:use midje.sweet)
  (:require [midje.repl :as midje]))

(defn -main []
  (facts "facts" 
    (fact "fact" 1 => 1))
  ;; Force Midje to output the final test summary
  (midje/print-summary))

Now when you run clj -A:test -m hello.test, you’ll see the success summary appear as expected.

Why This Happens

When you call facts or fact directly in your code, Midje executes the individual checks but doesn’t automatically generate the final summary. That summary logic is part of Midje’s runner (midje.run), which manages the full test lifecycle—from discovery to result reporting. Using a custom -main skips this runner, so you have to manually invoke the summary function to get that final success message.

Your deps.edn configuration is already correct: you’ve properly added the test directory to the classpath via the :test alias, and your Midje version is compatible with Clojure 1.9.

内容的提问来源于stack exchange,提问作者pdoherty926

相关产品推荐
方舟 Agent Plan

超全模态模型 × Harness 升级,最新支持 Deepseek-V4.1-Flash、GLM-5.3 系列、Doubao-Seedream-5.0-pro、Kimi-K3 (部分), 限时 9.9 元起

最近更新时间:2026.05.28 10:11:43