emacs-buttercup icon indicating copy to clipboard operation
emacs-buttercup copied to clipboard

Multiple before-all?

Open alphapapa opened this issue 8 years ago • 3 comments

Would it be possible to run a describe suite multiple times with different before-alls (and I guess after-alls too)? I need to run a suite multiple times with a slightly different before-all (finding a file normally and literally), and I'm not sure how to do this without duplicating the entire suite.

It would be nice to be able to do this similarly to how Travis can run multiple times with different Emacs versions with multiple values of the same variable in env.

I guess I could make a macro to wrap describe, calling it multiple times with a different before-all each time, but that seems...uh...messy... :)

Thanks.

alphapapa avatar Apr 13 '17 16:04 alphapapa

Hm. Tricky. Conceptually, I mean. Do you know of something like this in Jasmine or RSpec?

I think it would basically boil down to a macro as you describe, though, so I guess it's messy either way :-)

Maybe just put the actual test code into a function and call it from multiple describe/it blocks?

jorgenschaefer avatar Apr 14 '17 10:04 jorgenschaefer

I don't know anything about Jasmine or RSpec, sorry. :)

The tests in question are here, if it helps: https://github.com/alphapapa/helm-org-rifle/blob/master/test/helm-org-rifle-test.el The before-all finds the test data file, and I need to run the tests with both (find-file-noselect file) and (find-file-noselect file nil t). I'd like to be able to do that without duplicating all of the individual tests. I guess a macro is the only way.

It would be neat if there were something like:

(before-all-multi
  '((progn
      ;; First run
    )
    (progn
      ;; Second run
    )))

And the whole suite would be run for each form.

Thanks.

alphapapa avatar Apr 14 '17 16:04 alphapapa

I'd probably just define a helper function to run the test and do different setup/teardown code for each. Having lots of boiler plate code in the test can indicate a somewhat problematic API, but I do not know your project so this is nothing I can back with evidence :-D

jorgenschaefer avatar Apr 21 '17 09:04 jorgenschaefer