user1008893
user1008893

Reputation:

Parametrizing JUnit test with different data

I'm working on a Java webapp that might be causing me to misuse JUnit. I am building a multi-user interface for running JUnit tests. This is easy enough, but I can't figure out a way to indicate that User A wants to parametrize a JUnit test class with data X, and User B wants to parametrize with data Y.

Is this even possible? If not, I'd appreciate any suggestions. Thanks.

Upvotes: 0

Views: 190

Answers (1)

Raibaz
Raibaz

Reputation: 9700

How about using @RunWith(Parameterized.class) and @Parameters?

You should be able to run the same tests using data for different users, specifying different data sets in a method tagged with @Parametersthat returns a Collection that gets passed to the Test class constructor.

See http://www.mkyong.com/unittest/junit-4-tutorial-6-parameterized-test/

Upvotes: 5

Related Questions