-
Notifications
You must be signed in to change notification settings - Fork 84
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
Allow :kaocha.plugin.randomize/randomize? to be set at any test level #279
base: main
Are you sure you want to change the base?
Conversation
Hi @kennyjwilli , thanks for this! I had a first look through the diff. Not very in depth but generally I think it looks good.
That's fine, you can leave it there
Can you elaborate? Does this mean that passing
Good question. Since we first store the
Having a unit test like this is definitely useful, so you can go ahead and add them. I guess we could have a You can call individual plugin hooks as functions, e.g. (randomize-post-load-hook
{:kaocha.test-plan/tests
[{:kaocha.test-plan/id `a
:kaocha.testable/meta {::randomize? false}
:kaocha.test-plan/tests
[{:kaocha.test-plan/id `a1}
{:kaocha.test-plan/id `a2}]}
{:kaocha.test-plan/id `b
:kaocha.test-plan/tests
[{:kaocha.test-plan/id `b1}
{:kaocha.test-plan/id `b2}]}]
::randomize? true
::seed 1}) |
Seems we mainly mention the randomization feature in
and it's mentioned but not elaborated on in
Right, that's annoying... maybe do something like this? Then the order should matter less. Scenario: Using `--print-config`
When I run `bin/kaocha --print-config`
Then the output should contain:
""" clojure
:kaocha.plugin.randomize/randomize? false,
"""
And the output should contain:
""" clojure
:kaocha/reporter [kaocha.report/dots],
"""
And the output should contain:
""" clojure
:kaocha/color? false,
"""
And the output should contain:
""" clojure
:kaocha/fail-fast? false,
"""
And the output should contain:
""" clojure
:kaocha/tests
[{:kaocha.testable/type :kaocha.type/clojure.test,
:kaocha.testable/id :unit,
:kaocha/ns-patterns ["-test$"],
:kaocha/source-paths ["src"],
:kaocha/test-paths ["test"],
:kaocha.filter/skip-meta [:kaocha/skip]}],
""" |
Rereading this a few weeks later, I agree that the comment was not clear as all 😅 To answer your question, no, that's not what I meant. Passing
I went ahead and removed it. 9d5f3ed
Added. 5583cda
Added. LMK if you'd like any revisions, or go ahead and make any edits you'd like. e5f8a55 and 4edf409
Ok, so I updated the test to pass (5cd4553), but, for the life of me, I could not get the final block to pass, so I removed it. I pasted the failing output below, if you have any ideas on a fix. I'd also welcome advise on how to debug this. I see The final, failing block. And the output should contain:
""" clojure
:kaocha/tests
[{:kaocha.testable/type :kaocha.type/clojure.test,
:kaocha.testable/id :unit,
:kaocha/ns-patterns ["-test$"],
:kaocha/source-paths ["src"],
:kaocha/test-paths ["test"],
:kaocha.filter/skip-meta [:kaocha/skip]}],
""" ... and the output. FAIL in command-line.print-config/using---print-config (test/features/command_line/print_config.feature:30)
the output should contain:
Expected: (substring? needle haystack)
Haystack:
{:kaocha/tests
[{:kaocha.testable/type :kaocha.type/clojure.test,
:kaocha.testable/id :unit,
:kaocha/ns-patterns ["-test$"],
:kaocha/source-paths ["src"],
:kaocha/test-paths ["test"],
:kaocha.filter/skip-meta [:kaocha/skip]}],
:kaocha/fail-fast? false,
:kaocha/color? false,
:kaocha/cli-options {:config-file "tests.edn", :print-config true},
:kaocha.plugin.randomize/seed 551409332,
:kaocha.plugin.randomize/randomize? false,
:kaocha/plugins
[:kaocha.plugin/randomize
:kaocha.plugin/filter
:kaocha.plugin/capture-output],
:kaocha.plugin.capture-output/capture-output? true,
:kaocha/reporter [kaocha.report/dots]}
Needle:
:kaocha/tests
[{:kaocha.testable/type :kaocha.type/clojure.test,
:kaocha.testable/id :unit,
:kaocha/ns-patterns ["-test$"],
:kaocha/source-paths ["src"],
:kaocha/test-paths ["test"],
:kaocha.filter/skip-meta [:kaocha/skip]}],
╭───── Test output ───────────────────────────────────────────────────────
│ /var/folders/t2/bmd89mm95f5cynfdtwx1l11m0000gn/T/kaocha_integration10038483014523596160 $ bin/kaocha --print-config
│ stdout:
│ {:kaocha/tests
│ [{:kaocha.testable/type :kaocha.type/clojure.test,
│ :kaocha.testable/id :unit,
│ :kaocha/ns-patterns ["-test$"],
│ :kaocha/source-paths ["src"],
│ :kaocha/test-paths ["test"],
│ :kaocha.filter/skip-meta [:kaocha/skip]}],
│ :kaocha/fail-fast? false,
│ :kaocha/color? false,
│ :kaocha/cli-options {:config-file "tests.edn", :print-config true},
│ :kaocha.plugin.randomize/seed 551409332,
│ :kaocha.plugin.randomize/randomize? false,
│ :kaocha/plugins
│ [:kaocha.plugin/randomize
│ :kaocha.plugin/filter
│ :kaocha.plugin/capture-output],
│ :kaocha.plugin.capture-output/capture-output? true,
│ :kaocha/reporter [kaocha.report/dots]}
│
│ stderr:
│ Downloading: lambdaisland/kaocha-cloverage/maven-metadata.xml from datomic-cloud
│ Downloading: lambdaisland/kaocha-cloverage/maven-metadata.xml from cs-mvn
│ WARNING: Implicit use of clojure.main with options is deprecated, use -M
╰─────────────────────────────────────────────────────────────────────────
1 tests, 5 assertions, 1 failures.
|
Codecov ReportAttention: Patch coverage is
Additional details and impacted files@@ Coverage Diff @@
## main #279 +/- ##
==========================================
- Coverage 75.37% 75.35% -0.02%
==========================================
Files 51 51
Lines 2684 2690 +6
Branches 248 253 +5
==========================================
+ Hits 2023 2027 +4
Misses 504 504
- Partials 157 159 +2
Flags with carried forward coverage won't be shown. Click here to find out more. ☔ View full report in Codecov by Sentry. |
a569099
to
4e9e7e2
Compare
Fixes #272 by implementing @plexus's proposal here.
Comments and questions on the implementation.
or-some
to therandomize
namespace since it removed some repeated nestings. This macro could be moved to theutil
ns or removed altogether in favor of the nestedif-some
s.::seed
also means that the "forced"--no-randomize
CLI flag was not set. This could be passed explicitly by adding a new keyword.straight-sort
is called here, but I left it in.c-tests/foo/hello_test.clj
. This was painful since REPL restarts were necessary to detect changes to that file. I assume there's a way around that, but I did not dig. Instead I wrote a unit test forrng-sort
. I wasn't sure what the best approach for testing this was, so I left it off the draft version of the PR. Please let me know if there is a preference here. You can find the unit test below.command-line.print-config/using---print-config
test is failing because the output got reordered due to switching map implementations. It's difficult to make the new output order match the text inprint_config.feature
since it's in a less optimal order. Suggestions?