[Test] Parameterized tests

I never used a not-well-known functionality of junit 4. I mean: the Parameterized tests.
Every time i extract a method called "verifyXXXwith(parameter)" and i create a lot of small test case.
Reading this article: http://www.testearly.com/2007/04/13/take-heed-of-mixing-junit-4s-parameterized-tests/ i think my solution is the best.
What's your feedback?

3 commenti:

Unknown ha detto...

(Tom, the link is broken..)

I think they're more or less communicating in the same way.

But with separate test methods we COULD communicate much more, using method names to explain scenarios.

Consider for example:
@Parameters
public static Collection values() {
return Arrays.asList(new Object[][]{
{"-10", false }
});
}

A test method named "validationShouldBeFalseWithMinusTen" tells exacly the same.

But we can improve it, for example "negativeValuesShouldBeRejected", which tells something more.

What do you think about?

Tommaso Torti ha detto...

i agree

Luca ha detto...

When the number of parameters combinations is small and statically defined I prefer the way you suggested

When the number of parameters combinations is big, are written in a file or are generated at runtime by code I like more the other way