Displaying intermediate results for longer running tests?

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

Displaying intermediate results for longer running tests?

Jeff-351
I was hoping for some ideas on the most efficient "testng" way to periodically display progress for a long-running test.  

The test is a load test that runs on 50 threads and can take a while.  The issue is that the Continuous Deployment tool we use (GoCD) monitors output and if it doesn't see any will assume the test has hung and will kill the process.

I don't know that adding print statements to the actual test cases (with some timer/iteration logic, etc.) is the best way.  

In my mind the ideal would be to print out a status every N minutes something like:

[Status] 3654 of 282993 tests complete.

I'm not sure however if the total tests that could be run is available somewhere.  Regardless, I'm open to ideas.

Thanks!

--
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 [hidden email].
To post to this group, send email to [hidden email].
Visit this group at https://groups.google.com/group/testng-users.
For more options, visit https://groups.google.com/d/optout.
Reply | Threaded
Open this post in threaded view
|

Re: Displaying intermediate results for longer running tests?

⇜Krishnan Mahadevan⇝

Jeff,

 

How about you leveraging a listener such as this one?

 

import org.testng.IExecutionListener;
import org.testng.IInvokedMethod;
import org.testng.IInvokedMethodListener;
import org.testng.ITestResult;

import java.util.concurrent.TimeUnit;
import java.util.concurrent.atomic.AtomicInteger;

public class StatusReporter implements IInvokedMethodListener, IExecutionListener {
   
private final AtomicInteger counter = new AtomicInteger(0);
   
private volatile boolean stop = false;
   
private Thread thread;

   
public StatusReporter() {
        
thread = new Thread(new Runnable() {
           
@Override
           
public void run() {
               
while (true) {
                   
if (stop) {
                       
break;
                    }
                    System.
err.println("So far completed : " + counter.get() + " tests.");
                   
try {
                        TimeUnit.
MILLISECONDS.sleep(1000);
                    }
catch (InterruptedException e) {
                        e.printStackTrace();
                    }
                }
            }
        });

    }

   
@Override
   
public void beforeInvocation(IInvokedMethod method, ITestResult testResult) {
    }

   
@Override
   
public void afterInvocation(IInvokedMethod method, ITestResult testResult) {
       
if (method.isTestMethod()) {
           
counter.incrementAndGet();
        }
    }

   
@Override
   
public void onExecutionStart() {
       
thread.start();
    }

   
@Override
   
public void onExecutionFinish() {
       
stop = true;
       
thread.interrupt();
    }
}

 

 

 

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/

 

From: <[hidden email]> on behalf of Jeff <[hidden email]>
Reply-To: <[hidden email]>
Date: Wednesday, October 11, 2017 at 9:28 PM
To: "[hidden email]" <[hidden email]>
Subject: [testng-users] Displaying intermediate results for longer running tests?

 

I was hoping for some ideas on the most efficient "testng" way to periodically display progress for a long-running test.  

 

The test is a load test that runs on 50 threads and can take a while.  The issue is that the Continuous Deployment tool we use (GoCD) monitors output and if it doesn't see any will assume the test has hung and will kill the process.

 

I don't know that adding print statements to the actual test cases (with some timer/iteration logic, etc.) is the best way.  

 

In my mind the ideal would be to print out a status every N minutes something like:

 

[Status] 3654 of 282993 tests complete.

 

I'm not sure however if the total tests that could be run is available somewhere.  Regardless, I'm open to ideas.

 

Thanks!

--
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 [hidden email].
To post to this group, send email to [hidden email].
Visit this group at https://groups.google.com/group/testng-users.
For more options, visit https://groups.google.com/d/optout.

--
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 [hidden email].
To post to this group, send email to [hidden email].
Visit this group at https://groups.google.com/group/testng-users.
For more options, visit https://groups.google.com/d/optout.
Reply | Threaded
Open this post in threaded view
|

Re: Displaying intermediate results for longer running tests?

⇜Krishnan Mahadevan⇝

Forgot to add:

 

>>> I'm not sure however if the total tests that could be run is available somewhere

You are correct. AFAIK this information is not something that TestNG can determine before hand. So the only option is to show a status on how many tests have completed so far.

 

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/

 

From: Krishnan Mahadevan <[hidden email]>
Date: Wednesday, October 11, 2017 at 10:03 PM
To: <[hidden email]>
Subject: Re: [testng-users] Displaying intermediate results for longer running tests?

 

Jeff,

 

How about you leveraging a listener such as this one?

 

import org.testng.IExecutionListener;
import org.testng.IInvokedMethod;
import org.testng.IInvokedMethodListener;
import org.testng.ITestResult;

import java.util.concurrent.TimeUnit;
import java.util.concurrent.atomic.AtomicInteger;

public class StatusReporter implements IInvokedMethodListener, IExecutionListener {
   
private final AtomicInteger counter = new AtomicInteger(0);
   
private volatile boolean stop = false;
   
private Thread thread;

   
public StatusReporter() {
        
thread = new Thread(new Runnable() {
           
@Override
           
public void run() {
               
while (true) {
                   
if (stop) {
                       
break;
                    }
                    System.
err.println("So far completed : " + counter.get() + " tests.");
                   
try {
                        TimeUnit.
MILLISECONDS.sleep(1000);
                    }
catch (InterruptedException e) {
                        e.printStackTrace();
                    }
                }
            }
        });

    }

   
@Override
   
public void beforeInvocation(IInvokedMethod method, ITestResult testResult) {
    }

   
@Override
   
public void afterInvocation(IInvokedMethod method, ITestResult testResult) {
       
if (method.isTestMethod()) {
           
counter.incrementAndGet();
        }
    }

   
@Override
   
public void onExecutionStart() {
       
thread.start();
    }

   
@Override
   
public void onExecutionFinish() {
       
stop = true;
       
thread.interrupt();
    }
}

 

 

 

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/

 

From: <[hidden email]> on behalf of Jeff <[hidden email]>
Reply-To: <[hidden email]>
Date: Wednesday, October 11, 2017 at 9:28 PM
To: "[hidden email]" <[hidden email]>
Subject: [testng-users] Displaying intermediate results for longer running tests?

 

I was hoping for some ideas on the most efficient "testng" way to periodically display progress for a long-running test.  

 

The test is a load test that runs on 50 threads and can take a while.  The issue is that the Continuous Deployment tool we use (GoCD) monitors output and if it doesn't see any will assume the test has hung and will kill the process.

 

I don't know that adding print statements to the actual test cases (with some timer/iteration logic, etc.) is the best way.  

 

In my mind the ideal would be to print out a status every N minutes something like:

 

[Status] 3654 of 282993 tests complete.

 

I'm not sure however if the total tests that could be run is available somewhere.  Regardless, I'm open to ideas.

 

Thanks!

--
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 [hidden email].
To post to this group, send email to [hidden email].
Visit this group at https://groups.google.com/group/testng-users.
For more options, visit https://groups.google.com/d/optout.


--
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 [hidden email].
To post to this group, send email to [hidden email].
Visit this group at https://groups.google.com/group/testng-users.
For more options, visit https://groups.google.com/d/optout.
Reply | Threaded
Open this post in threaded view
|

Re: Displaying intermediate results for longer running tests?

Jeff-351
Perfect!  I tried experimenting with a simple IInvokedMethodListener2 implementation that I assign to each of the 3 test classes in question (using @Listeners).  The afterInvocation() method pulls the current test totals from the ITestContext instance every 30 seconds.  

The implementation is below.  I didn't put any code in the before***() methods or the after***() method that didn't have the ITestContext.  It seems to be working okay.

import java.text.SimpleDateFormat;
import java.time.Clock;
import java.time.Duration;
import java.time.Instant;
import org.apache.commons.lang3.time.DurationFormatUtils;
import org.testng.IInvokedMethod;
import org.testng.IInvokedMethodListener2;
import org.testng.ITestContext;
import org.testng.ITestResult;

public class TestNGStatusListener implements IInvokedMethodListener2 {

    static SimpleDateFormat format = new SimpleDateFormat("HH:mm:ss.SSS");

    Instant startTime = Instant.now(Clock.systemUTC());
    Instant lastOutput = Instant.now(Clock.systemUTC());

    @Override
    public void beforeInvocation(IInvokedMethod method, ITestResult testResult, ITestContext context) {
    }

    @Override
    public void afterInvocation(IInvokedMethod method, ITestResult testResult, ITestContext context) {
        Instant now = Instant.now(Clock.systemUTC());

        if (now.isAfter(lastOutput.plusSeconds(30))) {
            int skipped = context.getSkippedTests().size();
            int passed = context.getPassedTests().size();
            int failed = context.getFailedTests().size();

            System.out.println(String.format("[STATUS] Passed: %d  Failed: %d  Skipped: %d  Elapsed: %s",
                    passed, failed, skipped, DurationFormatUtils.formatDuration(Duration.between(startTime, now).toMillis(), "HHH:mm:ss.SSS")));
            lastOutput = now;
        }
    }

    @Override
    public void beforeInvocation(IInvokedMethod method, ITestResult testResult) {
    }

    @Override
    public void afterInvocation(IInvokedMethod method, ITestResult testResult) {
    }
}

Thanks!

On Wed, Oct 11, 2017 at 10:35 AM, Krishnan Mahadevan <[hidden email]> wrote:

Forgot to add:

 

>>> I'm not sure however if the total tests that could be run is available somewhere

You are correct. AFAIK this information is not something that TestNG can determine before hand. So the only option is to show a status on how many tests have completed so far.

 

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/

 

From: Krishnan Mahadevan <[hidden email]>
Date: Wednesday, October 11, 2017 at 10:03 PM
To: <[hidden email]>
Subject: Re: [testng-users] Displaying intermediate results for longer running tests?

 

Jeff,

 

How about you leveraging a listener such as this one?

 

import org.testng.IExecutionListener;
import org.testng.IInvokedMethod;
import org.testng.IInvokedMethodListener;
import org.testng.ITestResult;

import java.util.concurrent.TimeUnit;
import java.util.concurrent.atomic.AtomicInteger;

public class StatusReporter implements IInvokedMethodListener, IExecutionListener {
   
private final AtomicInteger counter = new AtomicInteger(0);
   
private volatile boolean stop = false;
   
private Thread thread;

   
public StatusReporter() {
        
thread = new Thread(new Runnable() {
           
@Override
           
public void run() {
               
while (true) {
                   
if (stop) {
                       
break;
                    }
                    System.
err.println("So far completed : " + counter.get() + " tests.");
                   
try {
                        TimeUnit.
MILLISECONDS.sleep(1000);
                    }
catch (InterruptedException e) {
                        e.printStackTrace();
                    }
                }
            }
        });

    }

   
@Override
   
public void beforeInvocation(IInvokedMethod method, ITestResult testResult) {
    }

   
@Override
   
public void afterInvocation(IInvokedMethod method, ITestResult testResult) {
       
if (method.isTestMethod()) {
           
counter.incrementAndGet();
        }
    }

   
@Override
   
public void onExecutionStart() {
       
thread.start();
    }

   
@Override
   
public void onExecutionFinish() {
       
stop = true;
       
thread.interrupt();
    }
}

 

 

 

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/

 

From: <[hidden email]> on behalf of Jeff <[hidden email]>
Reply-To: <[hidden email]>
Date: Wednesday, October 11, 2017 at 9:28 PM
To: "[hidden email]" <[hidden email]>
Subject: [testng-users] Displaying intermediate results for longer running tests?

 

I was hoping for some ideas on the most efficient "testng" way to periodically display progress for a long-running test.  

 

The test is a load test that runs on 50 threads and can take a while.  The issue is that the Continuous Deployment tool we use (GoCD) monitors output and if it doesn't see any will assume the test has hung and will kill the process.

 

I don't know that adding print statements to the actual test cases (with some timer/iteration logic, etc.) is the best way.  

 

In my mind the ideal would be to print out a status every N minutes something like:

 

[Status] 3654 of 282993 tests complete.

 

I'm not sure however if the total tests that could be run is available somewhere.  Regardless, I'm open to ideas.

 

Thanks!

--
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 [hidden email].
To post to this group, send email to [hidden email].
Visit this group at https://groups.google.com/group/testng-users.
For more options, visit https://groups.google.com/d/optout.


--
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 [hidden email].
To post to this group, send email to [hidden email].
Visit this group at https://groups.google.com/group/testng-users.
For more options, visit https://groups.google.com/d/optout.

--
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 [hidden email].
To post to this group, send email to [hidden email].
Visit this group at https://groups.google.com/group/testng-users.
For more options, visit https://groups.google.com/d/optout.
Reply | Threaded
Open this post in threaded view
|

Re: Displaying intermediate results for longer running tests?

⇜Krishnan Mahadevan⇝

Jeff,

That improvement was better than mine

Thanks for sharing it. Your implementation takes away the overhead of running a separate “timer” like thread.

 

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/

 

From: <[hidden email]> on behalf of Jeff <[hidden email]>
Reply-To: <[hidden email]>
Date: Wednesday, October 11, 2017 at 11:45 PM
To: "[hidden email]" <[hidden email]>
Subject: Re: [testng-users] Displaying intermediate results for longer running tests?

 

Perfect!  I tried experimenting with a simple IInvokedMethodListener2 implementation that I assign to each of the 3 test classes in question (using @Listeners).  The afterInvocation() method pulls the current test totals from the ITestContext instance every 30 seconds.  

 

The implementation is below.  I didn't put any code in the before***() methods or the after***() method that didn't have the ITestContext.  It seems to be working okay.

 

import java.text.SimpleDateFormat;

import java.time.Clock;

import java.time.Duration;

import java.time.Instant;

import org.apache.commons.lang3.time.DurationFormatUtils;

import org.testng.IInvokedMethod;

import org.testng.IInvokedMethodListener2;

import org.testng.ITestContext;

import org.testng.ITestResult;

 

public class TestNGStatusListener implements IInvokedMethodListener2 {

 

    static SimpleDateFormat format = new SimpleDateFormat("HH:mm:ss.SSS");

 

    Instant startTime = Instant.now(Clock.systemUTC());

    Instant lastOutput = Instant.now(Clock.systemUTC());

 

    @Override

    public void beforeInvocation(IInvokedMethod method, ITestResult testResult, ITestContext context) {

    }

 

    @Override

    public void afterInvocation(IInvokedMethod method, ITestResult testResult, ITestContext context) {

        Instant now = Instant.now(Clock.systemUTC());

 

        if (now.isAfter(lastOutput.plusSeconds(30))) {

            int skipped = context.getSkippedTests().size();

            int passed = context.getPassedTests().size();

            int failed = context.getFailedTests().size();

 

            System.out.println(String.format("[STATUS] Passed: %d  Failed: %d  Skipped: %d  Elapsed: %s",

                    passed, failed, skipped, DurationFormatUtils.formatDuration(Duration.between(startTime, now).toMillis(), "HHH:mm:ss.SSS")));

            lastOutput = now;

        }

    }

 

    @Override

    public void beforeInvocation(IInvokedMethod method, ITestResult testResult) {

    }

 

    @Override

    public void afterInvocation(IInvokedMethod method, ITestResult testResult) {

    }

}

 

Thanks!

 

On Wed, Oct 11, 2017 at 10:35 AM, Krishnan Mahadevan <[hidden email]> wrote:

Forgot to add:

 

>>> I'm not sure however if the total tests that could be run is available somewhere

You are correct. AFAIK this information is not something that TestNG can determine before hand. So the only option is to show a status on how many tests have completed so far.

 

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/

 

From: Krishnan Mahadevan <[hidden email]>
Date: Wednesday, October 11, 2017 at 10:03 PM
To: <[hidden email]>
Subject: Re: [testng-users] Displaying intermediate results for longer running tests?

 

Jeff,

 

How about you leveraging a listener such as this one?

 

import org.testng.IExecutionListener;
import org.testng.IInvokedMethod;
import org.testng.IInvokedMethodListener;
import org.testng.ITestResult;

import java.util.concurrent.TimeUnit;
import java.util.concurrent.atomic.AtomicInteger;

public class StatusReporter implements IInvokedMethodListener, IExecutionListener {
   
private final AtomicInteger counter = new AtomicInteger(0);
   
private volatile boolean stop = false;
   
private Thread thread;

   
public StatusReporter() {
        
thread = new Thread(new Runnable() {
           
@Override
           
public void run() {
               
while (true) {
                   
if (stop) {
                       
break;
                    }
                    System.
err.println("So far completed : " + counter.get() + " tests.");
                   
try {
                        TimeUnit.
MILLISECONDS.sleep(1000);
                    }
catch (InterruptedException e) {
                        e.printStackTrace();
                    }
                }
            }
        });

    }

   
@Override
   
public void beforeInvocation(IInvokedMethod method, ITestResult testResult) {
    }

   
@Override
   
public void afterInvocation(IInvokedMethod method, ITestResult testResult) {
       
if (method.isTestMethod()) {
           
counter.incrementAndGet();
        }
    }

   
@Override
   
public void onExecutionStart() {
       
thread.start();
    }

   
@Override
   
public void onExecutionFinish() {
       
stop = true;
       
thread.interrupt();
    }
}

 

 

 

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/

 

From: <[hidden email]> on behalf of Jeff <[hidden email]>
Reply-To: <[hidden email]>
Date: Wednesday, October 11, 2017 at 9:28 PM
To: "[hidden email]" <[hidden email]>
Subject: [testng-users] Displaying intermediate results for longer running tests?

 

I was hoping for some ideas on the most efficient "testng" way to periodically display progress for a long-running test.  

 

The test is a load test that runs on 50 threads and can take a while.  The issue is that the Continuous Deployment tool we use (GoCD) monitors output and if it doesn't see any will assume the test has hung and will kill the process.

 

I don't know that adding print statements to the actual test cases (with some timer/iteration logic, etc.) is the best way.  

 

In my mind the ideal would be to print out a status every N minutes something like:

 

[Status] 3654 of 282993 tests complete.

 

I'm not sure however if the total tests that could be run is available somewhere.  Regardless, I'm open to ideas.

 

Thanks!

--
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 [hidden email].
To post to this group, send email to [hidden email].
Visit this group at https://groups.google.com/group/testng-users.
For more options, visit https://groups.google.com/d/optout.

--
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 [hidden email].
To post to this group, send email to [hidden email].
Visit this group at https://groups.google.com/group/testng-users.
For more options, visit https://groups.google.com/d/optout.

 

--
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 [hidden email].
To post to this group, send email to [hidden email].
Visit this group at https://groups.google.com/group/testng-users.
For more options, visit https://groups.google.com/d/optout.

--
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 [hidden email].
To post to this group, send email to [hidden email].
Visit this group at https://groups.google.com/group/testng-users.
For more options, visit https://groups.google.com/d/optout.
Reply | Threaded
Open this post in threaded view
|

Re: Displaying intermediate results for longer running tests?

Jeff-351
Thanks!  Glad I'm on the right track :).  Sometimes I don't know.

On Wed, Oct 11, 2017 at 10:15 PM, Krishnan Mahadevan <[hidden email]> wrote:

Jeff,

That improvement was better than mine

Thanks for sharing it. Your implementation takes away the overhead of running a separate “timer” like thread.

 

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/

 

From: <[hidden email]> on behalf of Jeff <[hidden email]>
Reply-To: <[hidden email]>
Date: Wednesday, October 11, 2017 at 11:45 PM
To: "[hidden email]" <[hidden email]>


Subject: Re: [testng-users] Displaying intermediate results for longer running tests?

 

Perfect!  I tried experimenting with a simple IInvokedMethodListener2 implementation that I assign to each of the 3 test classes in question (using @Listeners).  The afterInvocation() method pulls the current test totals from the ITestContext instance every 30 seconds.  

 

The implementation is below.  I didn't put any code in the before***() methods or the after***() method that didn't have the ITestContext.  It seems to be working okay.

 

import java.text.SimpleDateFormat;

import java.time.Clock;

import java.time.Duration;

import java.time.Instant;

import org.apache.commons.lang3.time.DurationFormatUtils;

import org.testng.IInvokedMethod;

import org.testng.IInvokedMethodListener2;

import org.testng.ITestContext;

import org.testng.ITestResult;

 

public class TestNGStatusListener implements IInvokedMethodListener2 {

 

    static SimpleDateFormat format = new SimpleDateFormat("HH:mm:ss.SSS");

 

    Instant startTime = Instant.now(Clock.systemUTC());

    Instant lastOutput = Instant.now(Clock.systemUTC());

 

    @Override

    public void beforeInvocation(IInvokedMethod method, ITestResult testResult, ITestContext context) {

    }

 

    @Override

    public void afterInvocation(IInvokedMethod method, ITestResult testResult, ITestContext context) {

        Instant now = Instant.now(Clock.systemUTC());

 

        if (now.isAfter(lastOutput.plusSeconds(30))) {

            int skipped = context.getSkippedTests().size();

            int passed = context.getPassedTests().size();

            int failed = context.getFailedTests().size();

 

            System.out.println(String.format("[STATUS] Passed: %d  Failed: %d  Skipped: %d  Elapsed: %s",

                    passed, failed, skipped, DurationFormatUtils.formatDuration(Duration.between(startTime, now).toMillis(), "HHH:mm:ss.SSS")));

            lastOutput = now;

        }

    }

 

    @Override

    public void beforeInvocation(IInvokedMethod method, ITestResult testResult) {

    }

 

    @Override

    public void afterInvocation(IInvokedMethod method, ITestResult testResult) {

    }

}

 

Thanks!

 

On Wed, Oct 11, 2017 at 10:35 AM, Krishnan Mahadevan <[hidden email]> wrote:

Forgot to add:

 

>>> I'm not sure however if the total tests that could be run is available somewhere

You are correct. AFAIK this information is not something that TestNG can determine before hand. So the only option is to show a status on how many tests have completed so far.

 

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/

 

From: Krishnan Mahadevan <[hidden email]>
Date: Wednesday, October 11, 2017 at 10:03 PM
To: <[hidden email]>
Subject: Re: [testng-users] Displaying intermediate results for longer running tests?

 

Jeff,

 

How about you leveraging a listener such as this one?

 

import org.testng.IExecutionListener;
import org.testng.IInvokedMethod;
import org.testng.IInvokedMethodListener;
import org.testng.ITestResult;

import java.util.concurrent.TimeUnit;
import java.util.concurrent.atomic.AtomicInteger;

public class StatusReporter implements IInvokedMethodListener, IExecutionListener {
   
private final AtomicInteger counter = new AtomicInteger(0);
   
private volatile boolean stop = false;
   
private Thread thread;

   
public StatusReporter() {
        
thread = new Thread(new Runnable() {
           
@Override
           
public void run() {
               
while (true) {
                   
if (stop) {
                       
break;
                    }
                    System.
err.println("So far completed : " + counter.get() + " tests.");
                   
try {
                        TimeUnit.
MILLISECONDS.sleep(1000);
                    }
catch (InterruptedException e) {
                        e.printStackTrace();
                    }
                }
            }
        });

    }

   
@Override
   
public void beforeInvocation(IInvokedMethod method, ITestResult testResult) {
    }

   
@Override
   
public void afterInvocation(IInvokedMethod method, ITestResult testResult) {
       
if (method.isTestMethod()) {
           
counter.incrementAndGet();
        }
    }

   
@Override
   
public void onExecutionStart() {
       
thread.start();
    }

   
@Override
   
public void onExecutionFinish() {
       
stop = true;
       
thread.interrupt();
    }
}

 

 

 

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/

 

From: <[hidden email]> on behalf of Jeff <[hidden email]>
Reply-To: <[hidden email]>
Date: Wednesday, October 11, 2017 at 9:28 PM
To: "[hidden email]" <[hidden email]>
Subject: [testng-users] Displaying intermediate results for longer running tests?

 

I was hoping for some ideas on the most efficient "testng" way to periodically display progress for a long-running test.  

 

The test is a load test that runs on 50 threads and can take a while.  The issue is that the Continuous Deployment tool we use (GoCD) monitors output and if it doesn't see any will assume the test has hung and will kill the process.

 

I don't know that adding print statements to the actual test cases (with some timer/iteration logic, etc.) is the best way.  

 

In my mind the ideal would be to print out a status every N minutes something like:

 

[Status] 3654 of 282993 tests complete.

 

I'm not sure however if the total tests that could be run is available somewhere.  Regardless, I'm open to ideas.

 

Thanks!

--
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 [hidden email].
To post to this group, send email to [hidden email].
Visit this group at https://groups.google.com/group/testng-users.
For more options, visit https://groups.google.com/d/optout.

--
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 [hidden email].
To post to this group, send email to [hidden email].
Visit this group at https://groups.google.com/group/testng-users.
For more options, visit https://groups.google.com/d/optout.

 

--
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 [hidden email].
To post to this group, send email to [hidden email].
Visit this group at https://groups.google.com/group/testng-users.
For more options, visit https://groups.google.com/d/optout.

--
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 [hidden email].
To post to this group, send email to [hidden email].
Visit this group at https://groups.google.com/group/testng-users.
For more options, visit https://groups.google.com/d/optout.

--
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 [hidden email].
To post to this group, send email to [hidden email].
Visit this group at https://groups.google.com/group/testng-users.
For more options, visit https://groups.google.com/d/optout.