Skip to content

Cannot annotate Collections with @Datapoints, only arrays #110

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

Closed
MatrixFrog opened this issue Jun 3, 2010 · 7 comments
Closed

Cannot annotate Collections with @Datapoints, only arrays #110

MatrixFrog opened this issue Jun 3, 2010 · 7 comments
Labels

Comments

@MatrixFrog
Copy link

Currently, the @DataPoints annotation can only be applied to arrays, not Lists or other Collections, as described in http://stackoverflow.com/questions/2967912/junit-theories-why-cant-i-use-lists-instead-of-arrays-as-datapoints

It would be nice if you could use Lists as well, as they are often easier to work with.

@MatrixFrog
Copy link
Author

I've come up with a solution to this, which is still pretty rough. Rather than looking at the type of a Collection, to make sure that's a Collection where T is the datatype expected by the Theory, it just cycles through EVERY Collection that is annotated with @DataPoints and selects only the elements of type T. If you have a large collection of Strings, as well as a large collection of Integers, for example, this could potentially result in serious performance issues. But it does seem to work (I also included a small unit test). Please offer suggestions of how to improve it!

http://github.com/MatrixFrog/junit

@MatrixFrog
Copy link
Author

When I worked on this before, I didn't understand git very well, and it was also well before "Pull Requests 2.0" so I've redone it and cleaned up a little bit:

https://github.com/KentBeck/junit/pull/175

@dsaff dsaff mentioned this issue Feb 9, 2012
@dsaff
Copy link
Member

dsaff commented Mar 7, 2013

@pimterry, were you doing some work on this, or is my memory completely broken?

@pimterry
Copy link
Contributor

pimterry commented Mar 7, 2013

Yes, I was. Sorry I've got a bit delayed recently in tidying up the previous bits I started, but I'll try and get them and then this in within the next week or two :-)

@dsaff
Copy link
Member

dsaff commented Mar 7, 2013

No problem, just doing some people-to-issue bookkeeping. Thanks!

@Stephan202
Copy link
Contributor

It is my understanding that this issue has been resolved by #658; it should be closed.

@kcooney
Copy link
Member

kcooney commented Jul 11, 2014

Good point. Thanks, @Stephan202 !

@kcooney kcooney closed this as completed Jul 11, 2014
test-git-x-modules-app bot pushed a commit to vs/junit4 that referenced this issue Sep 13, 2022
SLF4J-218 removed org.apache.log4j.spi.Layout should be without "spi"
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

No branches or pull requests

5 participants