[infinispan-dev] A tip: Using a random word generator to generate uncommon test data

Galder Zamarreno galder.zamarreno at redhat.com
Tue Sep 15 06:31:58 EDT 2009



On 09/15/2009 12:14 PM, Galder Zamarreno wrote:
>
>
> On 09/15/2009 09:26 AM, Mircea Markus wrote:
>>
>> On Sep 14, 2009, at 12:02 PM, Galder Zamarreno wrote:
>>
>>>
>>>
>>> On 09/12/2009 12:31 AM, Michael Neale wrote:
>>>> A crazier alternative is to grab the testMethod name and use that as
>>>> part of the key/string - you can do it by getting the stack trace and
>>>> a little bit of work (I had a helper method somewhere).
>>>>
>>>> Something like:
>>>> Thread.currentThread().getStackTrace()(1).getMethodName() (at the top
>>>> of the test method)-- its probably 1 as 0 would be the getStackTrace
>>>> method itself... I have found it helpful when digging through things
>>>> and I see a value from a certain test...

Voila! Take your test method and add a java.lang.reflect.Method 
parameter to it. testng will populate it with the test method information:

    public void test000(java.lang.reflect.Method method) {
       System.out.println(method.getName());
    }

That will give you the test name without doing any fancy stuff :)
-- 
Galder Zamarreño
Sr. Software Engineer
Infinispan, JBoss Cache



More information about the infinispan-dev mailing list