Running tests which don't have TestNG annotations

classic Classic list List threaded Threaded
4 messages Options
Reply | Threaded
Open this post in threaded view
|

Running tests which don't have TestNG annotations

pbochel
Does TestNG have mechanism in which we could run Java an arbitrary java method?

The background to this question is that my project runs a lot of legacy tests which don't have TestNG annotations.
I know that I can list the tests in a suite.xml file and update the code so that it has @Test annotation. However, the problem with updating the code is that many of the tests come from a third party and for legal reasons we can't update the code.

My first thought is that what we really need is to define our own adapter which would know how to call our legacy tests, much like standard TestNG supports the calling of JUnit tests.
Is such an ability exposed?

Or perhaps there is already a way in which I can call arbitrary Java code?

Thanks,
Peter

--
You received this message because you are subscribed to the Google Groups "testng-users" group.
To unsubscribe from this group and stop receiving emails from it, send an email to [hidden email].
To post to this group, send email to [hidden email].
Visit this group at https://groups.google.com/group/testng-users.
For more options, visit https://groups.google.com/d/optout.
Reply | Threaded
Open this post in threaded view
|

Re: Running tests which don't have TestNG annotations

Cédric Beust ♔-2
Mmmh... not really. There is some flexibility built inside TestNG coming from the days when TestNG was working with real annotations and Javadoc annotations, but that support was never really exposed to make annotation discovery pluggable.

-- 
Cédric


On Mon, Feb 15, 2016 at 10:08 AM, <[hidden email]> wrote:
Does TestNG have mechanism in which we could run Java an arbitrary java method?

The background to this question is that my project runs a lot of legacy tests which don't have TestNG annotations.
I know that I can list the tests in a suite.xml file and update the code so that it has @Test annotation. However, the problem with updating the code is that many of the tests come from a third party and for legal reasons we can't update the code.

My first thought is that what we really need is to define our own adapter which would know how to call our legacy tests, much like standard TestNG supports the calling of JUnit tests.
Is such an ability exposed?

Or perhaps there is already a way in which I can call arbitrary Java code?

Thanks,
Peter

--
You received this message because you are subscribed to the Google Groups "testng-users" group.
To unsubscribe from this group and stop receiving emails from it, send an email to [hidden email].
To post to this group, send email to [hidden email].
Visit this group at https://groups.google.com/group/testng-users.
For more options, visit https://groups.google.com/d/optout.

--
You received this message because you are subscribed to the Google Groups "testng-users" group.
To unsubscribe from this group and stop receiving emails from it, send an email to [hidden email].
To post to this group, send email to [hidden email].
Visit this group at https://groups.google.com/group/testng-users.
For more options, visit https://groups.google.com/d/optout.
Reply | Threaded
Open this post in threaded view
|

Re: Running tests which don't have TestNG annotations

walter.kelt
In reply to this post by pbochel
Can you create your own test file using the testng annotations, and your file calls the test methods in the 3rd party file (assuming you know the
method names) ?? How you retrieve/analyze results would need to be worked out. Hopefully this shouldn't be too difficult.

something like..

@Test
public void runThirdPartyTest(String className, String methodName, String [] args ){
         try{
               try {
          Class classDefinition = Class.forName(className);   //3rd party test class name
          object = classDefinition.newInstance();             //create an instance, hopefully has zero arg constructor
          method = object.getClass().getDeclaredMethod(methodName,....); //find the 3rd party test method
          method.invoke(obj,args[0], args[1]....);                       //invoke the method... may, need to screen scrape for resu
                                                                         // lts
          :
          :
          :
      } catch (InstantiationException e) {
          System.out.println(e);
      } catch (IllegalAccessException e) {
          System.out.println(e);
      } catch (ClassNotFoundException e) {
          System.out.println(e);
      } catch (Throwable t) {
                //might want to put your own spin on failures
            }      
}


Perhaps this is what you meant by adapter...

Good Luck

On Monday, February 15, 2016 at 1:26:54 PM UTC-5, [hidden email] wrote:
Does TestNG have mechanism in which we could run Java an arbitrary java method?

The background to this question is that my project runs a lot of legacy tests which don't have TestNG annotations.
I know that I can list the tests in a suite.xml file and update the code so that it has @Test annotation. However, the problem with updating the code is that many of the tests come from a third party and for legal reasons we can't update the code.

My first thought is that what we really need is to define our own adapter which would know how to call our legacy tests, much like standard TestNG supports the calling of JUnit tests.
Is such an ability exposed?

Or perhaps there is already a way in which I can call arbitrary Java code?

Thanks,
Peter

--
You received this message because you are subscribed to the Google Groups "testng-users" group.
To unsubscribe from this group and stop receiving emails from it, send an email to [hidden email].
To post to this group, send email to [hidden email].
Visit this group at https://groups.google.com/group/testng-users.
For more options, visit https://groups.google.com/d/optout.
Reply | Threaded
Open this post in threaded view
|

Re: Running tests which don't have TestNG annotations

Krishnan Mahadevan
In reply to this post by Cédric Beust ♔-2
Peter,

You might want to take a look at this blog post of mine to see if that helps you

I tried using JavaAssist for byte code manipulation at runtime and then inject the @Test annotation into the byte code and then have TestNG use that to run it.

Thanks & Regards
Krishnan Mahadevan

"All the desirable things in life are either illegal, expensive, fattening or in love with someone else!"
My Scribblings @ http://wakened-cognition.blogspot.com/
My Technical Scribbings @ http://rationaleemotions.wordpress.com/

On Tue, Feb 16, 2016 at 11:52 AM, Cédric Beust ♔ <[hidden email]> wrote:
Mmmh... not really. There is some flexibility built inside TestNG coming from the days when TestNG was working with real annotations and Javadoc annotations, but that support was never really exposed to make annotation discovery pluggable.

-- 
Cédric


On Mon, Feb 15, 2016 at 10:08 AM, <[hidden email]> wrote:
Does TestNG have mechanism in which we could run Java an arbitrary java method?

The background to this question is that my project runs a lot of legacy tests which don't have TestNG annotations.
I know that I can list the tests in a suite.xml file and update the code so that it has @Test annotation. However, the problem with updating the code is that many of the tests come from a third party and for legal reasons we can't update the code.

My first thought is that what we really need is to define our own adapter which would know how to call our legacy tests, much like standard TestNG supports the calling of JUnit tests.
Is such an ability exposed?

Or perhaps there is already a way in which I can call arbitrary Java code?

Thanks,
Peter

--
You received this message because you are subscribed to the Google Groups "testng-users" group.
To unsubscribe from this group and stop receiving emails from it, send an email to [hidden email].
To post to this group, send email to [hidden email].
Visit this group at https://groups.google.com/group/testng-users.
For more options, visit https://groups.google.com/d/optout.

--
You received this message because you are subscribed to the Google Groups "testng-users" group.
To unsubscribe from this group and stop receiving emails from it, send an email to [hidden email].
To post to this group, send email to [hidden email].
Visit this group at https://groups.google.com/group/testng-users.
For more options, visit https://groups.google.com/d/optout.

--
You received this message because you are subscribed to the Google Groups "testng-users" group.
To unsubscribe from this group and stop receiving emails from it, send an email to [hidden email].
To post to this group, send email to [hidden email].
Visit this group at https://groups.google.com/group/testng-users.
For more options, visit https://groups.google.com/d/optout.