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

Multiple before-all? #75

Open
alphapapa opened this issue Apr 13, 2017 · 3 comments
Open

Multiple before-all? #75

alphapapa opened this issue Apr 13, 2017 · 3 comments

Comments

@alphapapa
Copy link
Contributor

alphapapa commented Apr 13, 2017

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.

@jorgenschaefer jorgenschaefer added this to the v1.6 milestone Apr 14, 2017
@jorgenschaefer
Copy link
Owner

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?

@alphapapa
Copy link
Contributor Author

alphapapa commented Apr 14, 2017

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.

@jorgenschaefer
Copy link
Owner

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 jorgenschaefer modified the milestones: v1.6, v1.18 May 20, 2017
@jorgenschaefer jorgenschaefer modified the milestones: v1.9, v1.10 Sep 29, 2017
@jorgenschaefer jorgenschaefer modified the milestones: v1.10, v1.11 Jan 28, 2018
@snogge snogge removed this from the v1.11 milestone Sep 16, 2020
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

3 participants