Dienstag, 2. März 2010

TwiP for Parameterized JUnit Tests

The native parameterized JUnit 4.X tests allows only one data set per test. With TwiP you can define one data set per test method, thats cool. Here a example  parameterized JUnit test with TwiP:

What not works in TwiP is the tree navigation (tested only in eclipse), because the mapping between the test tree result and the test methods is done by the name in the result tree. But TwiP add the paramter of the run in the name and then the mapping don't work :-( see the screenshot bellow, when you click on a test method you become a error dialog:



  1. Hi Christian,

    do you know of any way you can configure TwiP to feed your method with a parallel set of values?

    What I mean is that oftentimes what you want to test is your classes' output on a given set of input. So in a TwiP setup this could be:

    public void shouldDoSmtg(@Values("MY_STRING_VALUES") int value, @Values("MY_STRING_RESULTS") int result){
    // given an input is "value"

    // when I call my method with this value

    // then result_from_call == result?

    This ofcourse requires TwiP to iterate over @Values("MY_STRING_VALUES") & @Values("MY_STRING_RESULTS") (which should have the same length) in a parallel way.

    Any ideas?


  2. Hi Savvas,

    No, I do not know, but what a solution can be see my latest post -> http://tux2323.blogspot.com/2010/03/twip-junit-test-with-more-then-one.html

    Thanks for the comment


  3. Hi Christian,

    Seems interesting,
    thanks very much.