annotations issue

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

annotations issue

tarun3kumar
Hi there,

We are using testng5.2 for test case running. And there is one class that always gives us some failures, while it runs perfectly if we are using junit to execute.

I have a feeling this has something to do with the order of test case running. ( the test cases are running in wrong order), but I do not know why as our setting of  the annotations strictly folllows the rule.

I have both the test case java file and the testng runtime log file attached here.


Thank you for the helps !


Chun
---------------------------------------------------------------------
Posted via Jive Forums
http://forums.opensymphony.com/thread.jspa?threadID=53602&messageID=107705#107705


--~--~---------~--~----~------------~-------~--~----~
 You received this message because you are subscribed to the Google Groups "testng-users" group.
To post to this group, send email to [hidden email]
To unsubscribe from this group, send email to [hidden email]
For more options, visit this group at http://groups.google.com/group/testng-users?hl=en
-~----------~----~----~----~------~----~------~--~---

PurchaseOrderTest.java (46K) Download Attachment
Runtime.log (13K) Download Attachment
Reply | Threaded
Open this post in threaded view
|

Re: annotations issue

Alexandru Popescu ☀

I see your class is extending BillingTestCase. Is this one extending
the JUnit TestCase? If so, then you should know that you are not
allowed to mix TestNG features with JUnit features.

./alex
--
.w( the_mindstorm )p.
  TestNG co-founder
EclipseTestNG Creator


On 12/14/06, chun <[hidden email]> wrote:

> Hi there,
>
> We are using testng5.2 for test case running. And there is one class that always gives us some failures, while it runs perfectly if we are using junit to execute.
>
> I have a feeling this has something to do with the order of test case running. ( the test cases are running in wrong order), but I do not know why as our setting of  the annotations strictly folllows the rule.
>
> I have both the test case java file and the testng runtime log file attached here.
>
>
> Thank you for the helps !
>
>
> Chun
> ---------------------------------------------------------------------
> Posted via Jive Forums
> http://forums.opensymphony.com/thread.jspa?threadID=53602&messageID=107705#107705
>
>
> >
>
>

--~--~---------~--~----~------------~-------~--~----~
 You received this message because you are subscribed to the Google Groups "testng-users" group.
To post to this group, send email to [hidden email]
To unsubscribe from this group, send email to [hidden email]
For more options, visit this group at http://groups.google.com/group/testng-users?hl=en
-~----------~----~----~----~------~----~------~--~---

Reply | Threaded
Open this post in threaded view
|

Re: annotations issue

tarun3kumar

Hi Alex,

BillingTestCase.java has nothing to do with the Junit test case, this java file includes some information about sprintframework, and the values are need for our test cases, when there are class vs database table mapping.  


Chun Ji
---------------------------------------------------------------------
Posted via Jive Forums
http://forums.opensymphony.com/thread.jspa?threadID=53602&messageID=107714#107714


--~--~---------~--~----~------------~-------~--~----~
 You received this message because you are subscribed to the Google Groups "testng-users" group.
To post to this group, send email to [hidden email]
To unsubscribe from this group, send email to [hidden email]
For more options, visit this group at http://groups.google.com/group/testng-users?hl=en
-~----------~----~----~----~------~----~------~--~---

Reply | Threaded
Open this post in threaded view
|

Re: annotations issue

Cédric Beust ♔
Chun,

Your Java file seems to be empty, can you post it again?

Also, please include a description of how you run the two tests (the one that passes and the one that fails).

Thanks.

--
Cedric


On 12/14/06, chun <[hidden email]> wrote:

Hi Alex,

BillingTestCase.java has nothing to do with the Junit test case, this java file includes some information about sprintframework, and the values are need for our test cases, when there are class vs database table mapping.


Chun Ji
---------------------------------------------------------------------
Posted via Jive Forums
http://forums.opensymphony.com/thread.jspa?threadID=53602&messageID=107714#107714


--
Cédric
--~--~---------~--~----~------------~-------~--~----~
 You received this message because you are subscribed to the Google Groups "testng-users" group.
To post to this group, send email to [hidden email]
To unsubscribe from this group, send email to [hidden email]
For more options, visit this group at http://groups.google.com/group/testng-users?hl=en
-~----------~----~----~----~------~----~------~--~---

Reply | Threaded
Open this post in threaded view
|

Re: annotations issue

tarun3kumar
Hi Cedric,
We are running testng by using ANT on Linux.

All the test cases are listed in one testng xml file, and that xml file is specified in my build.xml. ( Here I have a sample "billing_testng.xml" attached. ). So during the runtime, I just call that target.  That is how these test cases are being executed.



Chun Ji
---------------------------------------------------------------------
Posted via Jive Forums
http://forums.opensymphony.com/thread.jspa?threadID=53602&messageID=107727#107727


--~--~---------~--~----~------------~-------~--~----~
 You received this message because you are subscribed to the Google Groups "testng-users" group.
To post to this group, send email to [hidden email]
To unsubscribe from this group, send email to [hidden email]
For more options, visit this group at http://groups.google.com/group/testng-users?hl=en
-~----------~----~----~----~------~----~------~--~---

billing_testng.xml (904 bytes) Download Attachment
PurchaseOrderTest.java (46K) Download Attachment
Reply | Threaded
Open this post in threaded view
|

Re: annotations issue

Alexandru Popescu ☀

On 12/14/06, chun <[hidden email]> wrote:
> Hi Cedric,
> We are running testng by using ANT on Linux.
>
> All the test cases are listed in one testng xml file, and that xml file is specified in my build.xml. ( Here I have a sample "billing_testng.xml" attached. ). So during the runtime, I just call that target.  That is how these test cases are being executed.
>
>

There is no obvious reason for your test to fail. However I see that
the order is not respected (according the log). Can you please show us
the fragment of you Ant build?

I am a bit confused as the source contains also JUnit related stuff.

./alex
--
.w( the_mindstorm )p.
  TestNG co-founder
EclipseTestNG Creator

>
> Chun Ji
> ---------------------------------------------------------------------
> Posted via Jive Forums
> http://forums.opensymphony.com/thread.jspa?threadID=53602&messageID=107727#107727
>
>
> >
>
>

--~--~---------~--~----~------------~-------~--~----~
 You received this message because you are subscribed to the Google Groups "testng-users" group.
To post to this group, send email to [hidden email]
To unsubscribe from this group, send email to [hidden email]
For more options, visit this group at http://groups.google.com/group/testng-users?hl=en
-~----------~----~----~----~------~----~------~--~---

Reply | Threaded
Open this post in threaded view
|

Re: annotations issue

Cédric Beust ♔
In reply to this post by tarun3kumar
Hi Chun,

Here is what I extracted from your source:

    @org.testng.annotations.Test
    public void testPopulateDatabase() {

    @org.testng.annotations.Test(dependsOnMethods = {"testPopulateDatabase"})
    public void testWrite() {

    @org.testng.annotations.Test(dependsOnMethods = {"testWrite"})
    public void testRead() {     

    @org.testng.annotations.Test(dependsOnMethods = {"testRead"})
    public void testGetRequisition() {

    @org.testng.annotations.Test(dependsOnMethods = {"testGetRequisition"})
    public void testCheckDuplicate() {

    @org.testng.annotations.Test(dependsOnMethods = {"testCheckDuplicate"})
    public void testDepleteFund() {

    @org.testng.annotations.Test(dependsOnMethods = {"testDepleteFund"})
    public void testTransfer() {

    @org.testng.annotations.Test(dependsOnMethods = {"testTransfer"})
    public void testCleanup(){       

Can you tell use which order you are seeing?

--
Cedric



On 12/14/06, chun <[hidden email]> wrote:
Hi Cedric,
We are running testng by using ANT on Linux.

All the test cases are listed in one testng xml file, and that xml file is specified in my build.xml. ( Here I have a sample "billing_testng.xml" attached. ). So during the runtime, I just call that target.  That is how these test cases are being executed.



Chun Ji
---------------------------------------------------------------------
Posted via Jive Forums
http://forums.opensymphony.com/thread.jspa?threadID=53602&messageID=107727#107727








--
Cédric
--~--~---------~--~----~------------~-------~--~----~
 You received this message because you are subscribed to the Google Groups "testng-users" group.
To post to this group, send email to [hidden email]
To unsubscribe from this group, send email to [hidden email]
For more options, visit this group at http://groups.google.com/group/testng-users?hl=en
-~----------~----~----~----~------~----~------~--~---

Reply | Threaded
Open this post in threaded view
|

Re: annotations issue

tarun3kumar
In reply to this post by Alexandru Popescu ☀

Now here is part of my build.xml that execute the testng.
"
<target name="test">
       <taskdef resource="testngtasks" classpath="/home/cji/testNG/testng-5.2-jdk15.jar"/>
    <testng classpathref="run.cp" outputdir="${test.output}"
        failureproperty="test.failed"  
        haltOnfailure="false"
        target="1.5"
        verbose="2">
        <xmlfileset dir="." includes="billing_testng.xml"/>
        <jvmarg value="-XX:PermSize=64m"/>
        <jvmarg value="-XX:MaxPermSize=128m"/>
   </testng>
</target>
"

One thing I am not sure is in this test Class,  it calls a
 "PurchaseOrderLineTest.getTestObjects()" to get an TestObject. It happens for several  This "PurchaseOrderLineTest" is another Junit Test Class located in the same package.

I was wondering if TESTNG can handle such scenario, or the "order of test cases" might be intervened because there are multiple Junit test classes involvoed. ?



Chun Ji
---------------------------------------------------------------------
Posted via Jive Forums
http://forums.opensymphony.com/thread.jspa?threadID=53602&messageID=107739#107739


--~--~---------~--~----~------------~-------~--~----~
 You received this message because you are subscribed to the Google Groups "testng-users" group.
To post to this group, send email to [hidden email]
To unsubscribe from this group, send email to [hidden email]
For more options, visit this group at http://groups.google.com/group/testng-users?hl=en
-~----------~----~----~----~------~----~------~--~---

Reply | Threaded
Open this post in threaded view
|

Re: annotations issue

tarun3kumar
In reply to this post by Cédric Beust ♔

Hi Alxe,
I thought the order that recorded in the runtime log file is the testcase running order under TESTNG, right ?

   [testng] testWrite()
   [testng] testRead()
   [testng] testCheckDuplicate()
   [testng] testGetIdProps()
   [testng] testCleanup()
   [testng] testPopulateDatabase()
   [testng] testDepleteFund()
   [testng] testTransfer()

Chun Ji
---------------------------------------------------------------------
Posted via Jive Forums
http://forums.opensymphony.com/thread.jspa?threadID=53602&messageID=107740#107740


--~--~---------~--~----~------------~-------~--~----~
 You received this message because you are subscribed to the Google Groups "testng-users" group.
To post to this group, send email to [hidden email]
To unsubscribe from this group, send email to [hidden email]
For more options, visit this group at http://groups.google.com/group/testng-users?hl=en
-~----------~----~----~----~------~----~------~--~---

Reply | Threaded
Open this post in threaded view
|

Re: annotations issue

tarun3kumar

Sorry, I mean

Hi Cedric,
....
---------------------------------------------------------------------
Posted via Jive Forums
http://forums.opensymphony.com/thread.jspa?threadID=53602&messageID=107741#107741


--~--~---------~--~----~------------~-------~--~----~
 You received this message because you are subscribed to the Google Groups "testng-users" group.
To post to this group, send email to [hidden email]
To unsubscribe from this group, send email to [hidden email]
For more options, visit this group at http://groups.google.com/group/testng-users?hl=en
-~----------~----~----~----~------~----~------~--~---

Reply | Threaded
Open this post in threaded view
|

Re: annotations issue

Cédric Beust ♔
In reply to this post by tarun3kumar
You are running your tests with junit="true" for each <test>.

Remove it.

And as Alexandru said earlier, you can't mix JUnit and TestNG runs in the same <test>, you'll need two separate <test> tags for that.

--
Cedric


On 12/14/06, chun <[hidden email]> wrote:

Hi Alxe,
I thought the order that recorded in the runtime log file is the testcase running order under TESTNG, right ?

   [testng] testWrite()
   [testng] testRead()
   [testng] testCheckDuplicate()
   [testng] testGetIdProps()
   [testng] testCleanup()
   [testng] testPopulateDatabase()
   [testng] testDepleteFund()
   [testng] testTransfer()

Chun Ji
---------------------------------------------------------------------
Posted via Jive Forums
http://forums.opensymphony.com/thread.jspa?threadID=53602&messageID=107740#107740


--
Cédric
--~--~---------~--~----~------------~-------~--~----~
 You received this message because you are subscribed to the Google Groups "testng-users" group.
To post to this group, send email to [hidden email]
To unsubscribe from this group, send email to [hidden email]
For more options, visit this group at http://groups.google.com/group/testng-users?hl=en
-~----------~----~----~----~------~----~------~--~---

Reply | Threaded
Open this post in threaded view
|

Re: annotations issue

tarun3kumar

Hi Cedric,
I don't quite understand the second part of your suggestion, what do  you mean "two separate <test> tags for that".

Following is my revised testng xml file.
"
 <!DOCTYPE suite SYSTEM "http://beust.com/testng/testng-1.0.dtd" >
 <suite name="billing">
...
  <test name="test.domain.billing.ProjectPositionBillingTest">
        <classes>
                <class name="com.....test.domain.billing.ProjectPositionBillingTest" />
        </classes>
  </test>
  <test name="test.domain.billing.PurchaseOrderChangeTest">
        <classes>
                <class name="com.....test.domain.billing.PurchaseOrderChangeTest"/>
        </classes>
  </test>
  <test name="test.domain.billing.PurchaseOrderLineTest">
        <classes>
                <class name="com.....test.domain.billing.PurchaseOrderLineTest"/>
        </classes>
  </test>
...
 </suite>
"

Thanks,


Chun Ji
---------------------------------------------------------------------
Posted via Jive Forums
http://forums.opensymphony.com/thread.jspa?threadID=53602&messageID=107760#107760


--~--~---------~--~----~------------~-------~--~----~
 You received this message because you are subscribed to the Google Groups "testng-users" group.
To post to this group, send email to [hidden email]
To unsubscribe from this group, send email to [hidden email]
For more options, visit this group at http://groups.google.com/group/testng-users?hl=en
-~----------~----~----~----~------~----~------~--~---

Reply | Threaded
Open this post in threaded view
|

Re: annotations issue

Cédric Beust ♔


On 12/14/06, chun <[hidden email]> wrote:

Hi Cedric,
I don't quite understand the second part of your suggestion, what do  you mean "two separate <test> tags for that".

Assume you have TNGTest (which is a TestNG test) and TJTest (which is a JUnit test), you would need to have:

<test name="Tng">
  <classes>
    <class name="TNGTest" />
  </classes>
</test>

<test name="TJunit" junit="true">
  <classes>
    <class name="TJTest" />
  </classes>
</test>


Following is my revised testng xml file.

This one looks good, what ordering of tests are you seeing now?


--
Cédric
 

"
<!DOCTYPE suite SYSTEM " http://beust.com/testng/testng-1.0.dtd" >
<suite name="billing">
...
  <test name="test.domain.billing.ProjectPositionBillingTest">
        <classes>
                <class name="com.....test.domain.billing.ProjectPositionBillingTest" />
        </classes>
  </test>
  <test name="test.domain.billing.PurchaseOrderChangeTest">
        <classes>
                <class name="com.....test.domain.billing.PurchaseOrderChangeTest"/>
        </classes>
  </test>
  <test name="test.domain.billing.PurchaseOrderLineTest">
        <classes>
                <class name="com.....test.domain.billing.PurchaseOrderLineTest"/>
        </classes>
  </test>
...
</suite>
"

Thanks,


Chun Ji
---------------------------------------------------------------------
Posted via Jive Forums
http://forums.opensymphony.com/thread.jspa?threadID=53602&messageID=107760#107760








--~--~---------~--~----~------------~-------~--~----~
 You received this message because you are subscribed to the Google Groups "testng-users" group.
To post to this group, send email to [hidden email]
To unsubscribe from this group, send email to [hidden email]
For more options, visit this group at http://groups.google.com/group/testng-users?hl=en
-~----------~----~----~----~------~----~------~--~---

Reply | Threaded
Open this post in threaded view
|

Re: annotations issue

tarun3kumar

Hi Cedric,
Can we just treat this test case is a junit test case, other than a TestNG Test Case ? I guess my question is from where you see this is a testNG test case ?
( Sorry I am asking such a junior question )

The other reason I am asking this is I have tried my revised testng xml file, and all test cases are either failed or skipped?

Chun
---------------------------------------------------------------------
Posted via Jive Forums
http://forums.opensymphony.com/thread.jspa?threadID=53602&messageID=107785#107785


--~--~---------~--~----~------------~-------~--~----~
 You received this message because you are subscribed to the Google Groups "testng-users" group.
To post to this group, send email to [hidden email]
To unsubscribe from this group, send email to [hidden email]
For more options, visit this group at http://groups.google.com/group/testng-users?hl=en
-~----------~----~----~----~------~----~------~--~---

Reply | Threaded
Open this post in threaded view
|

Re: annotations issue

Cédric Beust ♔


On 12/14/06, chun <[hidden email]> wrote:

Hi Cedric,
Can we just treat this test case is a junit test case, other than a TestNG Test Case ? I guess my question is from where you see this is a testNG test case ?

It's a TestNG test case because you are using TestNG annotations (@Test(dependsOnMethods...)).

If you run your class in JUnit mode, these annotations will simply be ignored, which is why you were seeing the seemingly random order of invocation.

--
Cédric
--~--~---------~--~----~------------~-------~--~----~
 You received this message because you are subscribed to the Google Groups "testng-users" group.
To post to this group, send email to [hidden email]
To unsubscribe from this group, send email to [hidden email]
For more options, visit this group at http://groups.google.com/group/testng-users?hl=en
-~----------~----~----~----~------~----~------~--~---

Reply | Threaded
Open this post in threaded view
|

Re: annotations issue

tarun3kumar
Hi Cedric,
I am running this test as a TestNG one now, and I do see all the test cases running in the order as I defined. Thank you !

But for some reason, it failed during the second one, "testWrite()". Attached is my new testng runtime log file.

Do you have any comments for it? Why the same code works as JUNIT mode, althrough it runs in the unexpected running order ?

Thanks again for all these messages.


chun ji
---------------------------------------------------------------------
Posted via Jive Forums
http://forums.opensymphony.com/thread.jspa?threadID=53602&messageID=108007#108007


--~--~---------~--~----~------------~-------~--~----~
 You received this message because you are subscribed to the Google Groups "testng-users" group.
To post to this group, send email to [hidden email]
To unsubscribe from this group, send email to [hidden email]
For more options, visit this group at http://groups.google.com/group/testng-users?hl=en
-~----------~----~----~----~------~----~------~--~---

testng.log (2K) Download Attachment
Reply | Threaded
Open this post in threaded view
|

Re: annotations issue

Cédric Beust ♔
Does this testWrite() method depend in any way on some JUnit behavior?  (such as a setUp() method)

--
Cedric


On 12/15/06, chun <[hidden email]> wrote:
Hi Cedric,
I am running this test as a TestNG one now, and I do see all the test cases running in the order as I defined. Thank you !

But for some reason, it failed during the second one, "testWrite()". Attached is my new testng runtime log file.

Do you have any comments for it? Why the same code works as JUNIT mode, althrough it runs in the unexpected running order ?

Thanks again for all these messages.


chun ji
---------------------------------------------------------------------
Posted via Jive Forums
http://forums.opensymphony.com/thread.jspa?threadID=53602&messageID=108007#108007








--
Cédric
--~--~---------~--~----~------------~-------~--~----~
 You received this message because you are subscribed to the Google Groups "testng-users" group.
To post to this group, send email to [hidden email]
To unsubscribe from this group, send email to [hidden email]
For more options, visit this group at http://groups.google.com/group/testng-users?hl=en
-~----------~----~----~----~------~----~------~--~---

Reply | Threaded
Open this post in threaded view
|

Re: annotations issue

tarun3kumar

I understand what you ask for. I would say "yes". So far, this is the most complicated "UNIT" test class that depends on a lot of other things, such as the other test class, etc.

So if that is the problem, is there another option for me, to use the testng framework to run the test, and to guarantee the running order of the test cases for this test?


Chun
---------------------------------------------------------------------
Posted via Jive Forums
http://forums.opensymphony.com/thread.jspa?threadID=53602&messageID=108022#108022


--~--~---------~--~----~------------~-------~--~----~
 You received this message because you are subscribed to the Google Groups "testng-users" group.
To post to this group, send email to [hidden email]
To unsubscribe from this group, send email to [hidden email]
For more options, visit this group at http://groups.google.com/group/testng-users?hl=en
-~----------~----~----~----~------~----~------~--~---

Reply | Threaded
Open this post in threaded view
|

Re: annotations issue

Cédric Beust ♔
If this test method depends on a setUp(), just add a @BeforeMethod annotation so that TestNG also sees it.

--
Cedric


On 12/15/06, chun < [hidden email]> wrote:

I understand what you ask for. I would say "yes". So far, this is the most complicated "UNIT" test class that depends on a lot of other things, such as the other test class, etc.

So if that is the problem, is there another option for me, to use the testng framework to run the test, and to guarantee the running order of the test cases for this test?


Chun
---------------------------------------------------------------------
Posted via Jive Forums
http://forums.opensymphony.com/thread.jspa?threadID=53602&messageID=108022#108022


--
Cédric
--~--~---------~--~----~------------~-------~--~----~
 You received this message because you are subscribed to the Google Groups "testng-users" group.
To post to this group, send email to [hidden email]
To unsubscribe from this group, send email to [hidden email]
For more options, visit this group at http://groups.google.com/group/testng-users?hl=en
-~----------~----~----~----~------~----~------~--~---

Reply | Threaded
Open this post in threaded view
|

Re: annotations issue

tarun3kumar

Hi Cedric,
I put this @BeforeMethod in, and it does not make any difference for my case.

Somehow, I think I have pinpointed where goes wrong. "testWrite()" calls another function "createTestObj()", which locates in the same class, and when it reaches.
    "
      GeneralService gs = (GeneralService) applicationContext.getBean("generalService");
   ",

it  gets "lost" and raised the  "java.lang.NullPointerException"  exception.



Any ideas why this happen ?


Chun Ji
---------------------------------------------------------------------
Posted via Jive Forums
http://forums.opensymphony.com/thread.jspa?threadID=53602&messageID=108062#108062


--~--~---------~--~----~------------~-------~--~----~
 You received this message because you are subscribed to the Google Groups "testng-users" group.
To post to this group, send email to [hidden email]
To unsubscribe from this group, send email to [hidden email]
For more options, visit this group at http://groups.google.com/group/testng-users?hl=en
-~----------~----~----~----~------~----~------~--~---

12