total test runtime in testng-results.xml

729 views
Skip to first unread message

mikkin

unread,
Mar 9, 2010, 4:13:51 PM3/9/10
to testng-users
Hi,

I was wondering if there is anyway that I can get the total runtime of
a test from testng-results.xml. I did see the duration-ms attribute of
test-method but simply adding all of them will not give me correct
time since we run our tests in parallel.

Thanks
Mikkin

Cédric Beust ♔

unread,
Mar 9, 2010, 4:19:16 PM3/9/10
to testng...@googlegroups.com
You're right that you probably can't derive this information from testng-results.xml, but you could measure this with  @BeforeSuite/@AfterSuite methods...

Of course, we could probably also add a <start-time> and <end-time> to testng-results.xml...

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




Cosmin Marginean

unread,
Mar 9, 2010, 4:24:05 PM3/9/10
to testng...@googlegroups.com
Yes, as I mentioned to Mikkin offline, this information is not available in testng-results.xml itself.
@Cédric - do you happen to know if this information is available in the TestNG API? I can remember this being asked before, but can't find anything relevant right now.

Otherwise is probably worth patching this as it shouldn't be that complicated.

Cosmin

Todd Wells

unread,
Mar 9, 2010, 4:27:14 PM3/9/10
to testng...@googlegroups.com
I think this would be useful information to have in testng-results.xml.

2010/3/9 Cédric Beust ♔ <cbe...@google.com>

mikkin

unread,
Mar 9, 2010, 5:05:24 PM3/9/10
to testng-users
Yeah, maybe something like adding an @total-time attribute to the
<suite> tag in testng-results.xml will be helpful.


-Mikkin


On Mar 9, 1:27 pm, Todd Wells <ttopwe...@gmail.com> wrote:
> I think this would be useful information to have in testng-results.xml.
>
> 2010/3/9 Cédric Beust ♔ <cbe...@google.com>
>
> > You're right that you probably can't derive this information from
> > testng-results.xml, but you could measure this with
> >  @BeforeSuite/@AfterSuite methods...
>
> > Of course, we could probably also add a <start-time> and <end-time> to
> > testng-results.xml...
>
> > --

> > ***Cédric
> > *


>
> > On Tue, Mar 9, 2010 at 1:13 PM, mikkin <mikkinpa...@gmail.com> wrote:
>
> >> Hi,
>
> >> I was wondering if there is anyway that I can get the total runtime of
> >> a test from testng-results.xml. I did see the duration-ms attribute of
> >> test-method but simply adding all of them will not give me correct
> >> time since we run our tests in parallel.
>
> >> Thanks
> >> Mikkin
>
> >> --
> >> 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<testng-users%2Bunsu...@googlegroups.com>


> >> .
> >> For more options, visit this group at
> >>http://groups.google.com/group/testng-users?hl=en.
>
> >  --
> > 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<testng-users%2Bunsu...@googlegroups.com>

Cosmin Marginean

unread,
Mar 10, 2010, 3:29:03 AM3/10/10
to testng...@googlegroups.com
@Cédric - I wrote a patch for this (at suite and testcase level).
Let me know if you're happy with it and if we can have a beta build available.

Thanks,
Cosmin

Cédric Beust ♔

unread,
Mar 10, 2010, 12:20:16 PM3/10/10
to testng...@googlegroups.com
Cosmin just implemented this for you:

  <suite name="TestNG JDK 1.5" duration-ms="35041" started-at="2010-03-10T09:15:36Z" finished-at="2010-03-10T09:16:11Z">

Available in the beta:  http://testng.org/beta

Thanks, Cosmin!

-- 
Cédric

mikkin

unread,
Mar 10, 2010, 5:35:42 PM3/10/10
to testng-users
Great!

Thanks Cosmin and Cedric! :)

-Mikkin

On Mar 10, 9:20 am, Cédric Beust ♔ <cbe...@google.com> wrote:
> Cosmin just implemented this for you:
>
>   <suite name="TestNG JDK 1.5" duration-ms="35041"
> started-at="2010-03-10T09:15:36Z" finished-at="2010-03-10T09:16:11Z">
>
> Available in the beta:  http://testng.org/beta
>
> Thanks, Cosmin!
>
> --

> ***Cédric
> *


>
> On Tue, Mar 9, 2010 at 1:27 PM, Todd Wells <ttopwe...@gmail.com> wrote:
> > I think this would be useful information to have in testng-results.xml.
>
> > 2010/3/9 Cédric Beust ♔ <cbe...@google.com>
>
> >> You're right that you probably can't derive this information from
> >> testng-results.xml, but you could measure this with
> >>  @BeforeSuite/@AfterSuite methods...
>
> >> Of course, we could probably also add a <start-time> and <end-time> to
> >> testng-results.xml...
>
> >> --

> >> ***Cédric
> >> *


>
> >> On Tue, Mar 9, 2010 at 1:13 PM, mikkin <mikkinpa...@gmail.com> wrote:
>
> >>> Hi,
>
> >>> I was wondering if there is anyway that I can get the total runtime of
> >>> a test from testng-results.xml. I did see the duration-ms attribute of
> >>> test-method but simply adding all of them will not give me correct
> >>> time since we run our tests in parallel.
>
> >>> Thanks
> >>> Mikkin
>
> >>> --
> >>> 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<testng-users%2Bunsu...@googlegroups.com>


> >>> .
> >>> For more options, visit this group at
> >>>http://groups.google.com/group/testng-users?hl=en.
>
> >>  --
> >> 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<testng-users%2Bunsu...@googlegroups.com>


> >> .
> >> For more options, visit this group at
> >>http://groups.google.com/group/testng-users?hl=en.
>
> >  --
> > 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<testng-users%2Bunsu...@googlegroups.com>

Eric Young

unread,
Oct 2, 2015, 5:58:48 PM10/2/15
to testng-users, cosm...@gmail.com
Hi, Cosmin, I want to know how it is got implemented. Appreciate if you can give some clues. 

Thanks,
Eric



.
For more options, visit this group at
http://groups.google.com/group/testng-users?hl=en.
        
 --
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

Krishnan Mahadevan

unread,
Oct 2, 2015, 10:57:23 PM10/2/15
to testng...@googlegroups.com
Eric,

You can perhaps create a TestNG listener such as the one below and wire it to your tests.

public class TimeKeeper implements ISuiteListener {
public static final String pattern = "dd/MM/yyyy HH:mm:ss SS";
public static final SimpleDateFormat format = new SimpleDateFormat(pattern);

@Override
public void onStart(ISuite suite) {

}

@Override
public void onFinish(ISuite suite) {
long totalTime = 0;
for (ISuiteResult eachResult : suite.getResults().values()) {
ITestContext ctx = eachResult.getTestContext();
Date start = ctx.getStartDate();
Date end = ctx.getEndDate();
long ms = end.getTime() - start.getTime();
totalTime += ms;
System.err.println(ctx.getName() + " started at [" + format.format(start) + "] and "
+ "ended at [" + format.format(end) + "] and took [" + ms + "] ms to run.");
}
System.err.println("Total time taken = " + totalTime + " ms");

}
}

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/

.
For more options, visit this group at
http://groups.google.com/group/testng-users?hl=en.
        
 --
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
.
For more options, visit this group at
http://groups.google.com/group/testng-users?hl=en.
      

--
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 testng-users...@googlegroups.com.

To post to this group, send email to testng...@googlegroups.com.
Reply all
Reply to author
Forward
0 new messages