btm / minitest-handler-cookbook

Apache License 2.0
59 stars 36 forks source link

Remove recipe name matching requirement #69

Closed martinb3 closed 9 years ago

martinb3 commented 9 years ago

In def test_files..., you have:

files << test_file if test_file_name == "#{recipe_name}_test.rb"

I have logical test grouping by file, right now, and I don't want to put it all into one giant file for the recipe being tested. Right now, I have tests for a cluster node, tests for a single node... all different ways of converging a single recipe.

Could you at least do a substring match here? Or just don't filter at all? It doesn't hurt anything to copy all the test files, and filter them on runtime, right? Thanks.

dpetzel commented 9 years ago

Hey @martinb3,

It doesn't hurt anything to copy all the test files

In a previous release it was specifically requested to avoid this exact situation. In order to speed things up this filtering was implemented to avoid copying files that would never get executed. I'm not sure it makes sense to undo that behavior.

Would it be possible for you to supply a more concrete example of your use case? At first glance, I wonder if Chefspec wouldn't be a more appropriate method of testing all the different ways of converging a single recipe. Given that Minitest requires an actual convergence, you need a new/fresh VM for each variation to truly ensure things are working. I'm also wondering if you wouldn't be better served by splitting your recipes out in a similar fashion to your test files. IE _cluster, _single_node, etc. Doing that would conform to the existing conventions of how this handler is used. Again, these are fairly random suggestions, and I'm sure we can figure out a solution that works for everyone.

Thanks

martinb3 commented 9 years ago

My use case is simply that I'm grouping related tests into different files. I agree with moving to chefspec, but unfortunately I'm writing tests for a project I don't necessarily have control over... the recipe I've got is actually not very big or complex, but it does have some major branches in logic -- it's those branches that I'm testing using multiple test files.

Perhaps this could be exposed as an option, for the people who do want to have more elaborate file naming options than <recipe>_test.rb?

Thank you for your feedback! In any case, I've managed to embark on a longer rewrite that will probably result in switching to chefspec, so this is a moot point for me. Maybe the issue will at least serve to document for others. Feel free to close. Thank you!

dpetzel commented 9 years ago

@martinb3 No problem. I'm going to close for now, but if you ever feel the need, I'm happy to revisit and figure out a good option.