Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Ignore reports from test.check #18

Open
wants to merge 3 commits into
base: master
Choose a base branch
from
Open

Conversation

jcf
Copy link
Contributor

@jcf jcf commented Jul 18, 2017

I haven't tested this out; just made the change via the GitHub web UI.

Doesn't work!

</testcase>{:result true, :num-tests 100, :seed 1500396702425, :test-var "t-task->request-valid-request"}
<testcase name="t-task-&gt;request-valid-request"

@@ -127,3 +127,9 @@
(defmethod report :error [m]
(test/inc-report-counter :error)
(push-result m))


Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Whoops! Too many new lines.

@jcf jcf reopened this Jul 18, 2017
@jcf
Copy link
Contributor Author

jcf commented Jul 18, 2017

Reopening this as I think the approach may be sound but we need to maybe change the way the JUnit reporter is configured because there will always be more output on stdout than just the XML.

@weavejester
Copy link
Owner

weavejester commented Jul 18, 2017

There shouldn't be; *test-out* should be solely reserved for the test reporters. There may be functions that write to *out*, but that shouldn't affect *test-out* if it's rebound to a file writer.

@jcf
Copy link
Contributor Author

jcf commented Jul 19, 2017

@weavejester I added an integration test that captures the output from running tests and it looks like this:

lein test :only eftest.report-test/test-junit-reporter

FAIL in (test-junit-reporter) (report_test.clj:10)
expected: (= "" out)
  actual: (not (= "" "<?xml version=\"1.0\" encoding=\"UTF-8\"?>\n<testsuites><testsuite name=\"core-test\" package=\"example\"><testcase name=\"b-test\" classname=\"example.core-test\"></testcase><testcase name=\"a-test\" classname=\"example.core-test\"><failure>expected: (= 0 1)\n  actual: (not (= 0 1))\n      at: core_test.clj:7</failure>\n</testcase></testsuite></testsuites>\nError encountered performing task 'eftest' with profile(s): 'base,system,user,provided,dev,junit'\nTests failed.\n"))

You can see the XML from the JUnit formatter, and then "Error encountered performing task 'eftest'…". Given that we probably always want the JUnit report in a file and not printed to stdout, maybe requiring a path where we write the XML is a good solution?

@jcf
Copy link
Contributor Author

jcf commented Jul 19, 2017

To enable writing to a file from the Leiningen plugin, two options spring to mind.

The first would be to allow more than just a symbol in the :eftest map in project.clj, and would necessitate changing the require-form and report-namespace fns I think.

(defn- report-namespace [project]
  (-> project :eftest (:report 'eftest.report.progress/report) namespace symbol))

(defn- require-form [project]
  `(require 'eftest.runner '~(report-namespace project)))

Alternatively, we could add an additional option to the project.clj map of something like :file or :output-path that would be used with eftest.report/report-to-file.

:eftest {:report eftest.report.junit/report
         :output-path "target/junit.xml"}

We could even support an environment variable as test2junit does, but I suppose people can use ~(System/getenv "JUNIT_OUTPUT_PATH") from their project.clj.

Maybe you have a better idea?

@weavejester
Copy link
Owner

I like the idea of adding an option, perhaps :output-file, that would wrap the reporter in report-to-file.

@jcf
Copy link
Contributor Author

jcf commented Sep 20, 2017

I like the idea of adding an option, perhaps :output-file, that would wrap the reporter in report-to-file.

I can use :output-file instead of :report-to-file if you prefer.

@jcf
Copy link
Contributor Author

jcf commented Sep 20, 2017

See #25 for the ability to redirect test output to a file, which will be useful here too.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

2 participants