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

Support generation of "looped testcases" in testrunner. #144

Closed
bavovanachte opened this issue Nov 21, 2015 · 4 comments
Closed

Support generation of "looped testcases" in testrunner. #144

bavovanachte opened this issue Nov 21, 2015 · 4 comments

Comments

@bavovanachte
Copy link

Hi,

In our team we're considering switching to Unity for our unit testing needs, the automatic test runner generation being one of the key decision factors for switching.
However, I don't seem to find any support for looped testcases in the test runner generation (which could be useful for sweeping the full input range of a function, with data stored in arrays).

Is this feature deliberately left out? Or does it make sense for me to adapt generate_test_runner.rb to support this feature and push it back to you?

Thanks!
Bavo

@mvandervoord
Copy link
Member

Bavo:

This is a feature that was added to the test runner generator quite awhile back. If you have generate_test_runner dump its help, you'll see it has the option for "--use_param_tests=1" which will enable the feature you are looking for. I'm not 100% sure it still works. We don't often have people making use of it. It's currently on the list of things to likely be removed from future iterations.

Most users tend to prefer explicitly adding their own loops, making it clear to all those who look at the test what is being iterated over or what parameter sets are being attempted.

If I have misunderstood and this isn't what you are talking about, I apologize. Please reexplain. ;)

@bavovanachte
Copy link
Author

Hey,

My goal is not so much to pass arguments to functions, just to loop the testcase N times. I can fetch the right data in the test by using a global array and a simple counter. The idea is just to make sure every element of the array is tested, and it doesn't stop on the first failure (which would happen if I wrote it in a for loop in a single test case).

I'll take a look at the "--use_param_tests" option. Thanks!

@alejmrm
Copy link
Contributor

alejmrm commented Sep 22, 2016

you should also look at this pending pull request:
#64

It might be what you need.

@bavovanachte
Copy link
Author

Well, our use case is the following:

For complex mathematical functions in C, we would create a model in either matlab of python, and generate a testdata table from that model for testing the C implementation. This testdata would typically be contained in a separate generated file, and would not likely be continuous.

We have found solutions for this problem in our own unit testing framework, so if it's not a common use case, feel free to close this issue. Thanks for the quick response, though.

korigod added a commit to korigod/Unity that referenced this issue Feb 2, 2020
TEST_RANGE([start, stop, step]) generates following runs of the test
function: test(start), test(start + step), ..., test(start + n * step),
where start + n * step <= stop. The step must be positive.

If the test function takes several arguments, the following syntax must be used:
TEST_RANGE([arg1_start, arg1_stop, arg1_step], ..., [argN_start, argN_stop, argN_step])

This addresses issues ThrowTheSwitch#53 and ThrowTheSwitch#144.

Reported-by: Alex Rodriguez <alejmrm@gmail.com>
Reported-by: Hiroaki Yamazoe <PastelParasol@gmail.com>
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

No branches or pull requests

3 participants