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

Manik Surtani manik at jboss.org
Wed Sep 23 13:34:20 EDT 2009


On 15 Sep 2009, at 11:31, Galder Zamarreno wrote:

>
>
> 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 :)

Nice!
--
Manik Surtani
manik at jboss.org
Lead, Infinispan
Lead, JBoss Cache
http://www.infinispan.org
http://www.jbosscache.org







More information about the infinispan-dev mailing list