RetryAnalyzerCount with dataproviders

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

RetryAnalyzerCount with dataproviders

testnguser-5
Hello,

I have a RetryTest class which extends RetryAnalyzerCount. It works perfectly for tests that have one test case in the dataprovider. If there are two test cases and both fails, it reruns the test only for the first testcase. If it passes for this rerun, it goes to the next test and does not rerun with the second test case in the same data provider.

Is this the usual behavior?

Thanks!

--
You received this message because you are subscribed to the Google Groups "testng-users" group.
To view this discussion on the web visit https://groups.google.com/d/msg/testng-users/-/dB1gbwmYxSIJ.
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: RetryAnalyzerCount with dataproviders

吴亭
After investigate the source code, currently, if you use the retry and dataprovider, retry method will only use the fist parameters to do the retry.

For example, due to this method will always return to the false, the first method {1,false} will use three times retry.

When the second method {0, true} failed, there is no counter to execute retry method.

  public RetryAnalyzerTest() {
    setCount(3);
  }

  @DataProvider(name="dataProvider")
  private Object[][] dataProvider() {
    return new Object[][] { { 1, false }, { 0, true } };
  }

   @Test(retryAnalyzer=RetryAnalyzerTest.class, dataProvider="dataProvider")
  public void testAnnotationWithDataProvider(int paf, boolean test) {
      System.out.println(paf + " "+test);
      System.out.println("-----------------------");
      System.out.println("Test method was called");
      Assert.assertTrue(false);
  }

2012/7/19 testnguser <[hidden email]>
Hello,

I have a RetryTest class which extends RetryAnalyzerCount. It works perfectly for tests that have one test case in the dataprovider. If there are two test cases and both fails, it reruns the test only for the first testcase. If it passes for this rerun, it goes to the next test and does not rerun with the second test case in the same data provider.

Is this the usual behavior?

Thanks!

--
You received this message because you are subscribed to the Google Groups "testng-users" group.
To view this discussion on the web visit https://groups.google.com/d/msg/testng-users/-/dB1gbwmYxSIJ.
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.

--
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: RetryAnalyzerCount with dataproviders

testnguser-5
Exactly, is there any other way(other than testng-failed.xml) to retry a failed method? Thanks!

On Thu, Jul 19, 2012 at 6:29 AM, 吴亭 <[hidden email]> wrote:
After investigate the source code, currently, if you use the retry and dataprovider, retry method will only use the fist parameters to do the retry.

For example, due to this method will always return to the false, the first method {1,false} will use three times retry.

When the second method {0, true} failed, there is no counter to execute retry method.

  public RetryAnalyzerTest() {
    setCount(3);
  }

  @DataProvider(name="dataProvider")
  private Object[][] dataProvider() {
    return new Object[][] { { 1, false }, { 0, true } };
  }

   @Test(retryAnalyzer=RetryAnalyzerTest.class, dataProvider="dataProvider")
  public void testAnnotationWithDataProvider(int paf, boolean test) {
      System.out.println(paf + " "+test);
      System.out.println("-----------------------");
      System.out.println("Test method was called");
      Assert.assertTrue(false);
  }

2012/7/19 testnguser <[hidden email]>
Hello,

I have a RetryTest class which extends RetryAnalyzerCount. It works perfectly for tests that have one test case in the dataprovider. If there are two test cases and both fails, it reruns the test only for the first testcase. If it passes for this rerun, it goes to the next test and does not rerun with the second test case in the same data provider.

Is this the usual behavior?

Thanks!

--
You received this message because you are subscribed to the Google Groups "testng-users" group.
To view this discussion on the web visit https://groups.google.com/d/msg/testng-users/-/dB1gbwmYxSIJ.
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.

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

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

Distinguishing between Methods that are Test Methods and Methods that are just there to support Methods

Kevin Simonson

When I create the following code in IntelliJ:,

 

---Abc.java---------------------------------------------------------------------

 

package org.familysearch.links.uitests;

 

import org.testng.annotations.*;

 

@Test(enabled = false, groups = "xyz")

public class Abc {

 

  @BeforeClass(alwaysRun = true)

  private void def () {

 

    System.out.println( "Beginning of {def()}.");

    String user      = "me"

    String password  = "em";

    String sessionId = pqr( user, password);

    System.out.println( "End of {def()}.");

  }

 

  public void ghi () {

    System.out.println( "In {ghi()}.");

  }

 

  public void jkl () {

    System.out.println( "In {jkl()}.");

  }

 

  public void mno () {

    System.out.println( "In {mno()}.");

  }

 

  public String pqr ( String username

                    , String password) {

    System.out.println( "In {pqr()}.");

    return "Success!";

  }

}

--------------------------------------------------------------------------------

 

and right click outside of any method and click on <Run 'Abc'>, I get the following output:

 

--------------------------------------------------------------------------------

Beginning of {def()}.

In {pqr()}.

End of {def()}.

In {ghi()}.

In {jkl()}.

In {mno()}.

--------------------------------------------------------------------------------

 

So TestNG knows somehow that {ghi()}, {jkl()}, and {mno()} are test methods, and should be run independently of any other methods, and it knows somehow that {pqr()} is not a test method, and should only be run when it's called by {def()}.  My question is, how does TestNG tell that {pqr()} is not a test method like the other three test methods?  It's inside class {Abc}, and {Abc} has the {@Test} annotation right before it; why aren't all methods inside {Abc} test methods?  Is it the fact that {pqr()} has parameters and doesn't have a data provider that distinguishes it from the other test methods?

 

Kevin S

 



NOTICE: This email message is for the sole use of the intended recipient(s) and may contain confidential and privileged information. Any unauthorized review, use, disclosure or distribution is prohibited. If you are not the intended recipient, please contact the sender by reply email and destroy all copies of the original message.


--
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: Distinguishing between Methods that are Test Methods and Methods that are just there to support Methods

Cédric Beust ♔-2
Hi Kevin,

You figured it out: the fact that this method takes parameters and doesn't have a data provider or a @Parameter annotation tells TestNG it's not a test method (and besides, TestNG wouldn't know how to call it since it doesn't know what parameters to pass).

-- 
Cédric




On Thu, Jul 19, 2012 at 11:12 AM, Kevin Simonson <[hidden email]> wrote:

When I create the following code in IntelliJ:,

 

---Abc.java---------------------------------------------------------------------

 

package org.familysearch.links.uitests;

 

import org.testng.annotations.*;

 

@Test(enabled = false, groups = "xyz")

public class Abc {

 

  @BeforeClass(alwaysRun = true)

  private void def () {

 

    System.out.println( "Beginning of {def()}.");

    String user      = "me"

    String password  = "em";

    String sessionId = pqr( user, password);

    System.out.println( "End of {def()}.");

  }

 

  public void ghi () {

    System.out.println( "In {ghi()}.");

  }

 

  public void jkl () {

    System.out.println( "In {jkl()}.");

  }

 

  public void mno () {

    System.out.println( "In {mno()}.");

  }

 

  public String pqr ( String username

                    , String password) {

    System.out.println( "In {pqr()}.");

    return "Success!";

  }

}

--------------------------------------------------------------------------------

 

and right click outside of any method and click on <Run 'Abc'>, I get the following output:

 

--------------------------------------------------------------------------------

Beginning of {def()}.

In {pqr()}.

End of {def()}.

In {ghi()}.

In {jkl()}.

In {mno()}.

--------------------------------------------------------------------------------

 

So TestNG knows somehow that {ghi()}, {jkl()}, and {mno()} are test methods, and should be run independently of any other methods, and it knows somehow that {pqr()} is not a test method, and should only be run when it's called by {def()}.  My question is, how does TestNG tell that {pqr()} is not a test method like the other three test methods?  It's inside class {Abc}, and {Abc} has the {@Test} annotation right before it; why aren't all methods inside {Abc} test methods?  Is it the fact that {pqr()} has parameters and doesn't have a data provider that distinguishes it from the other test methods?

 

Kevin S

 



NOTICE: This email message is for the sole use of the intended recipient(s) and may contain confidential and privileged information. Any unauthorized review, use, disclosure or distribution is prohibited. If you are not the intended recipient, please contact the sender by reply email and destroy all copies of the original message.


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

--
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: RetryAnalyzerCount with dataproviders

吴亭
In reply to this post by testnguser-5
Hi,

If you could try the latest version of testng (TestNG 6.8 -snapshot version)

You can orverride retry method in your test case like this, (3 is a retry number, you can update it according to your test cases.)

    @Override
    public boolean retry(ITestResult result) {
        boolean retry = false;
        int count = getCount();
        if (count > 0) {
            retry = retryMethod(result);
        }
        setCount(--count);

        if (getCount()==-1){
            setCount(3);
        }
        return retry;
    }

2012/7/20 tech hari <[hidden email]>
Exactly, is there any other way(other than testng-failed.xml) to retry a failed method? Thanks!


On Thu, Jul 19, 2012 at 6:29 AM, 吴亭 <[hidden email]> wrote:
After investigate the source code, currently, if you use the retry and dataprovider, retry method will only use the fist parameters to do the retry.

For example, due to this method will always return to the false, the first method {1,false} will use three times retry.

When the second method {0, true} failed, there is no counter to execute retry method.

  public RetryAnalyzerTest() {
    setCount(3);
  }

  @DataProvider(name="dataProvider")
  private Object[][] dataProvider() {
    return new Object[][] { { 1, false }, { 0, true } };
  }

   @Test(retryAnalyzer=RetryAnalyzerTest.class, dataProvider="dataProvider")
  public void testAnnotationWithDataProvider(int paf, boolean test) {
      System.out.println(paf + " "+test);
      System.out.println("-----------------------");
      System.out.println("Test method was called");
      Assert.assertTrue(false);
  }

2012/7/19 testnguser <[hidden email]>
Hello,

I have a RetryTest class which extends RetryAnalyzerCount. It works perfectly for tests that have one test case in the dataprovider. If there are two test cases and both fails, it reruns the test only for the first testcase. If it passes for this rerun, it goes to the next test and does not rerun with the second test case in the same data provider.

Is this the usual behavior?

Thanks!

--
You received this message because you are subscribed to the Google Groups "testng-users" group.
To view this discussion on the web visit https://groups.google.com/d/msg/testng-users/-/dB1gbwmYxSIJ.
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.

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

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

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