annotations issue

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

Re: annotations issue

Alexandru Popescu ☀

You rely on setUp/tearDown methods to initialize your application
context. For the same behavior you must either use @BeforeClass +
@AfterClass or @BeforeMethod + @AfterMethod; also please note that
this will only guarantee that those methods are called nothing else.
So, you must check your test hierarchy and understand what should
happen before a test method is run and what should happen afterwards.

On the same idea, I would kindly ask you to consult the public
documentation, as most of your questions so far were already answered
in there.

good luck,

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


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

>
> 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
-~----------~----~----~----~------~----~------~--~---

Reply | Threaded
Open this post in threaded view
|

Re: annotations issue

tarun3kumar
In reply to this post by tarun3kumar
Here is more information about this "applicationContext".

This testcase extends from BillingTestCase.java, so if you take a look at this java file ( Attached), you may see itself defived from
"
org.springframework.test.AbstractDependencyInjectionSpringContextTests
",

that is where this applicationContext defined, and if we are using it to create our own objects, all we need to do is to make a call such as:  
"
Obj myobj = (Obj) applicationContext.getBean("ObjName").
".

hope it helps


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


--~--~---------~--~----~------------~-------~--~----~
 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
-~----------~----~----~----~------~----~------~--~---

BillingTestCase.java (484 bytes) Download Attachment
Reply | Threaded
Open this post in threaded view
|

Re: annotations issue

Alexandru Popescu ☀

I am not sure how to make it more clear than I did before: you are
using a test hierarchy whose behavior is determined by JUnit lifecyle
and without any changes you are trying to run it under TestNG (and not
in JUnit compatible mode). This is not possible.

If you check that class you will see that it is a smart extension over
JUnit TestCase that retrieves the context and initialize it inside
your test class. If you run the test class with TestNG without JUnit
compatible mode then the lifecycle is completely different.

There is some similar AbstractDependencyInjectionSpringContextTests
available in TestNG sources which may help you reproduce the behavior.

However, once again, I would encourage you to read the documentation.

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


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

> Here is more information about this "applicationContext".
>
> This testcase extends from BillingTestCase.java, so if you take a look at this java file ( Attached), you may see itself defived from
> "
> org.springframework.test.AbstractDependencyInjectionSpringContextTests
> ",
>
> that is where this applicationContext defined, and if we are using it to create our own objects, all we need to do is to make a call such as:
> "
> Obj myobj = (Obj) applicationContext.getBean("ObjName").
> ".
>
> hope it helps
>
>
> Chun Ji
> ---------------------------------------------------------------------
> Posted via Jive Forums
> http://forums.opensymphony.com/thread.jspa?threadID=53602&messageID=108071#108071
>
>
> >
>
>

--~--~---------~--~----~------------~-------~--~----~
 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

So do I have the option to run this test class t with TestNG with JUnit
compatible mode and how ?

( Sorry, I could not find this answer in www.testng.org.)

Thank you for having answer that many trivial questions.


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


--~--~---------~--~----~------------~-------~--~----~
 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