testng-results.xml is invalid w/ surefire

141 views
Skip to first unread message

Colin

unread,
Feb 10, 2012, 6:41:23 PM2/10/12
to testng-users
Hello,

I'm using testng 6.3.1 w/ maven 3.0.4/surefire 2.10 and I'm seeing
incorrect entries in the target/surefire-reports/testng-results.xml
file. I noticed this because this is the file Jenkins (appears to)
parse so I see incorrect test results in jenkins.

My first question is.. does testng actually create the testng-
results.xml file? If not please let me know who to ask about this.

But assuming testng does create it, I see invalid entries such as
this:

<class name="com.lim.cd.config.HttpClientFactoryTest">
<test-method status="PASS" signature="setup()[pri:0,
instance:com.lim.cd.config.HttpClientFactoryTest@18a9fc8]"
name="setup" is-config="true" duration-ms="14" started-
at="2012-02-10T17:25:10Z" finished-at="2012-02-10T17:25:10Z">
</test-method>
<test-method status="PASS" signature="setupDbUnit()[pri:0,
instance:com.lim.cd.service.logging.dao.LoggingDaoTest@68cd79]"
name="setupDbUnit" is-config="true" duration-ms="1014" started-
at="2012-02-10T17:25:10Z" finished-at="2012-02-10T17:25:11Z">
</test-method>
<test-method status="PASS" signature="setUp()[pri:0,
instance:com.lim.cd.service.mimws.http.HttpMimWsServiceTest@1c6e818]"
name="setUp" is-config="true" duration-ms="0" started-
at="2012-02-10T17:25:10Z" finished-at="2012-02-10T17:25:10Z">
</test-method>

[.. the rest omitted...]

The first test-method is correct and it references my @BeforeTest
setup() method in HttpClientFactoryTest. But the other two methods
are in completely different classes.. I don't understand why they are
here.

Any advice greatly appreciated. And please set me straight if I
should be asking these questions in the surefire forums instead. It's
not clear to me who is generating what in the surefire-reports
directory.

Thank you,
Colin

Cédric Beust ♔

unread,
Feb 10, 2012, 9:45:50 PM2/10/12
to testng...@googlegroups.com
Hi Colin,

This definitely looks like a TestNG issue, so you're at the right place.

Can you reproduce the problem on a small project or ideally just one class? If yes, then please email me that class.

Thanks.

-- 
Cédric




Colin

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


Colin

unread,
Feb 12, 2012, 5:21:28 PM2/12/12
to testng-users
Hi Cédric,

I looked into this issue and it seems I was misunderstanding how
@BeforeTest works. I thought @BeforeTest methods would execute before
any @Test methods in the same class, but they in fact execute before
any @Test methods in any class. Normally I only run individual tests
in Eclipse, so this distinction didn't matter. But once I ran the
whole test suite this causes an issue.

While investigating I read about @BeforeClass, which is what I should
have used in the first place. One question tho, must methods
annotated with @BeforeClass be static? if not are they guaranteed to
be called immediately after the class constructor?

Thank you,
Colin

Cédric Beust ♔

unread,
Feb 12, 2012, 5:29:44 PM2/12/12
to testng...@googlegroups.com
@BeforeClass doesn't need to be static.

As for @BeforeTest, I think you still misunderstand it: it runs before the <test> tag.

@BeforeMethod is what runs before each test method.

-- 
Cédric

Reply all
Reply to author
Forward
0 new messages