cognitect-labs / test-runner

A test runner for clojure.test
Eclipse Public License 2.0
288 stars 32 forks source link

Add support for alternative outputs #13

Open SevereOverfl0w opened 6 years ago

SevereOverfl0w commented 6 years ago

My particular use-case is JUnit on CI systems, meaning two features are needed:

  1. Wrapping with-junit-output around running the tests
  2. Writing the output to a file for the CI to read

I have resolved both of these.

There is no standard parameterization system for clojure test output wrappers. I think it is reasonable for users to create a macro which adds the parameters they need, for parameterized output wrappers.

frenchy64 commented 3 years ago

It's hard to confirm exactly what's happening, but this PR seems to not work when there are zero tests to run.

Expected output:


Running tests in #{"test"}

Testing user

Ran 0 tests containing 0 assertions.
0 failures, 0 errors.

With this PR:

Checking out: https://github.com/typedclojure/test-runner at 3228fb6cf5df0212be90bf97288944bd29e25bee

Running tests in #{"test"}
Syntax error (UnsupportedOperationException) compiling fn* at (REPL:0:0).
Unknown Collection type

Full report at:
/var/folders/0j/2dr2jp4175q1zjmh254tv_fr0000gp/T/clojure-9022130043830287682.edn
{:clojure.main/message
 "Syntax error (UnsupportedOperationException) compiling fn* at (REPL:0:0).\nUnknown Collection type\n",
 :clojure.main/triage
 {:clojure.error/phase :compile-syntax-check,
  :clojure.error/line 0,
  :clojure.error/column 0,
  :clojure.error/symbol fn*,
  :clojure.error/class java.lang.UnsupportedOperationException,
  :clojure.error/cause "Unknown Collection type"},
 :clojure.main/trace
 {:via
  [{:type clojure.lang.Compiler$CompilerException,
    :message "Syntax error compiling fn* at (0:0).",
    :data
    {:clojure.error/phase :compile-syntax-check,
     :clojure.error/line 0,
     :clojure.error/column 0,
     :clojure.error/source "NO_SOURCE_PATH",
     :clojure.error/symbol fn*},
    :at [clojure.lang.Compiler analyzeSeq "Compiler.java" 7119]}
   {:type java.lang.UnsupportedOperationException,
    :message "Unknown Collection type",
    :at [clojure.lang.Compiler$EmptyExpr emit "Compiler.java" 2987]}],
  :trace
  [[clojure.lang.Compiler$EmptyExpr emit "Compiler.java" 2987]
   [clojure.lang.Compiler$InvokeExpr
    emitArgsAndCall
    "Compiler.java"
    3787]
   [clojure.lang.Compiler$InvokeExpr emit "Compiler.java" 3729]
   [clojure.lang.Compiler$BodyExpr emit "Compiler.java" 6164]
   [clojure.lang.Compiler$TryExpr emit "Compiler.java" 2216]
   [clojure.lang.Compiler$BodyExpr emit "Compiler.java" 6164]
   [clojure.lang.Compiler$LetExpr doEmit "Compiler.java" 6523]
   [clojure.lang.Compiler$LetExpr emit "Compiler.java" 6473]
   [clojure.lang.Compiler$BodyExpr emit "Compiler.java" 6164]
   [clojure.lang.Compiler$ObjMethod emitBody "Compiler.java" 5864]
   [clojure.lang.Compiler$FnMethod doEmitStatic "Compiler.java" 5519]
   [clojure.lang.Compiler$FnMethod emit "Compiler.java" 5484]
   [clojure.lang.Compiler$FnExpr emitMethods "Compiler.java" 3948]
   [clojure.lang.Compiler$ObjExpr compile "Compiler.java" 4584]
   [clojure.lang.Compiler$FnExpr parse "Compiler.java" 4110]
   [clojure.lang.Compiler analyzeSeq "Compiler.java" 7109]
   [clojure.lang.Compiler analyze "Compiler.java" 6793]
   [clojure.lang.Compiler eval "Compiler.java" 7178]
   [clojure.lang.Compiler eval "Compiler.java" 7136]
   [clojure.core$eval invokeStatic "core.clj" 3202]
   [clojure.core$eval invoke "core.clj" 3198]
   [cognitect.test_runner$test invokeStatic "test_runner.clj" 76]
   [cognitect.test_runner$test invoke "test_runner.clj" 57]
   [cognitect.test_runner$_main invokeStatic "test_runner.clj" 130]
   [cognitect.test_runner$_main doInvoke "test_runner.clj" 119]
   [clojure.lang.RestFn applyTo "RestFn.java" 137]
   [clojure.lang.Var applyTo "Var.java" 705]
   [clojure.core$apply invokeStatic "core.clj" 667]
   [clojure.main$main_opt invokeStatic "main.clj" 514]
   [clojure.main$main_opt invoke "main.clj" 510]
   [clojure.main$main invokeStatic "main.clj" 664]
   [clojure.main$main doInvoke "main.clj" 616]
   [clojure.lang.RestFn applyTo "RestFn.java" 137]
   [clojure.lang.Var applyTo "Var.java" 705]
   [clojure.main main "main.java" 40]],
  :cause "Unknown Collection type",
  :phase :compile-syntax-check}}