[testng-users] Spring 2.5 & TestNG - Sequence of Initialization

78 views
Skip to first unread message

Tom Hain

unread,
Oct 30, 2007, 11:39:44 AM10/30/07
to testng...@googlegroups.com

I started to use Spring 2.5 in my tests and I observed the following behavior
in combination with TestNG.

My tests extend the spring class AbstractTestNGSpringContextTests.

I implemented a couple of tests and for all of them I'd like to setup the
tests using a @BeforeSuite annotated method. Within this method I
instantiate some classes via the applicationContext.

The point is, the applicationContext is loaded after execution of the
@BeforeSuite annotated method.

This is not what I would expect. How is it intended to initialize the tests
?

The sequence of execution is like this:

...
[Invoker 2745175] Invoking @BeforeSuite test.Init.setUp()
...
2007-10-30 16:20:30,562 DEBUG
[org.springframework.test.context.support.AbstractGenericContextLoader] -
Loading ApplicationContext for locations
[classpath:/testing-config.xml,classpath:/testing-config.xml].
...


--
View this message in context: http://www.nabble.com/Spring-2.5---TestNG---Sequence-of-Initialization-tf4719321.html#a13491227
Sent from the testng-users mailing list archive at Nabble.com.

Cédric Beust ♔

unread,
Oct 30, 2007, 12:10:25 PM10/30/07
to testng...@googlegroups.com
I'm not familiar with this area unfortunately, and I'm sure somebody will come up with a more useful response than mine, but my first suggestion would be to ask on the Spring mailing-list exactly what triggers the creation of the application context...

--
Cédric

Tom Hain

unread,
Nov 1, 2007, 10:18:12 AM11/1/07
to testng...@googlegroups.com

Hi Cédric,

I posted a similar message in the spring forum and in the meanwhile I am
pretty sure that Spring needs to be changed in a way that the
applicationContext is even set when @BeforeSuite is called.

Currently the spring context is set on @BeforeClass Level as you can see in
the sourcecode below:
/**
* Delegates to the configured {@link TestContextManager} to
* {@link TestContextManager#prepareTestInstance(Object) prepare} this test
* instance prior to execution of any individual test methods, for example
* for injecting dependencies, etc.
*
* @throws Throwable if a registered TestExecutionListener throws an
* exception.
*/
@BeforeClass(groups = { "SpringTestContext" })
protected void springTestContextPrepareTestInstance() throws Throwable {
this.testContextManager.prepareTestInstance(this);
}

However, I did not get a response so far and I just posting this again here,
because somewhere in this forum I read that you guys have been involved in
the discussion about the new testing framework in spring together with the
people from interface21.
That's why I was just wondering what your statement is about this...
Maybe I misuse TestNG in combination with Spring - on the other hand using
spring the very first thing what needs to be done is accessing the
application context and the very first step in TestNg is @BeforeSuite, isn't
it?

And my question to the community is: Did somebody else use Spring 2.5 in
combination with TestNG already and what are the experiences so far?

--
View this message in context: http://www.nabble.com/Spring-2.5---TestNG---Sequence-of-Initialization-tf4719321.html#a13529679

Alexandru Popescu ☀

unread,
Nov 7, 2007, 10:16:45 PM11/7/07
to testng...@googlegroups.com
Hi Tom!

I've been in vacation for the last couple of weeks, so I haven't
really got the time to look over the integration with Spring.
Hopefully, I will be able to start looking into this in the upcoming
weeks (even if I will have to catch up with my work).

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

Tom Hain

unread,
Nov 9, 2007, 3:38:24 AM11/9/07
to testng...@googlegroups.com

Hi,

this is in fact a change which needs to be done in Spring.
See: http://forum.springframework.org/showthread.php?t=45603

Let's wait for the next built of Spring 2.5...

Cheers,

Tom

--
View this message in context: http://www.nabble.com/Spring-2.5---TestNG---Sequence-of-Initialization-tf4719321.html#a13663221

Reply all
Reply to author
Forward
0 new messages