borojevic
unread,Oct 9, 2009, 8:06:24 AM10/9/09Sign in to reply to author
Sign in to forward
You do not have permission to delete messages in this group
Either email addresses are anonymous for this group or you need the view member email addresses permission to view the original message
to testng-dev
Hi all,
I read some posts about this interface and tried to use it.
This interface is great idea, but in my opinion there are some things
to be improved.
Please correct me if I am wrong!
1. You can specify IRetryAnalyzer on the class level.
In this case it is applied for all test methods.
Usually I want to specify maximum number of retries, but this does not
exist and I have to code this.
Something like this:
public class Analyzer implements IRetryAnalyzer {
private int count = 0;
public static int MAX_RETRY_COUNT = 2;
public boolean retry(ITestResult result) {
count++;
if(count <= MAX_RETRY_COUNT){
System.out.println(count + "Analyzer says we should rerun test " +
result.getName());
return true;
}else{
return false;
}
}
}
Test class itself:
@Test(retryAnalyzer = Analyzer.class )
public class ClassicTest {
public void testCLI(){
System.out.println("Testing testCLI");
Assert.fail("Failing in order to test retry analyzer");
}
public void testMSISDN(){
System.out.println("Testing testMSISDN");
Assert.fail("Failing in order to test retry analyzer");
}
public void testFixnet(){
System.out.println("Testing testFixnet");
Assert.fail("Failing in order to test retry analyzer");
}
}
PROBLEM:
Analyzer instance is created once(as expected) and testCLI method is
invoked 2 times(probably because it is invoked first) , but the other
methods are invoked only once.
This is because variable count is incremented and logic in retry
method will now return false.
What should be done?
1. Implement functionality to specify maximum number of retries in
analyzer.
In addition, new instance of retry analyzer should be applied for each
test method. This is just to avoid situations like in example above.
2. Implement the functionality so it is possible to specify retry
analyzer for class, test, test method, suite.
For the test method should remain as it is, no need to implement
something new.
4. Hierarchy precedence - test method analyzer takes precedence over
class level analyzer, class level analyzer takes precedence over test
level analyzer,
test level analyzer takes precedence over suite level analyzer.
This is just a basic idea. I probably did not think about many
situation that can occur, but this is not bad start point to improve
IRetryAnalyzer as
I find this interface very usefull.
What other people think about this?
Regards,
Aleksandar