01: package test.invocationcount;
02:
03: import org.testng.annotations.AfterMethod;
04: import org.testng.annotations.BeforeClass;
05: import org.testng.annotations.BeforeMethod;
06: import org.testng.annotations.Test;
07:
08: @Test(groups="first")
09: public class InvocationCountOnlyFirstTimeTest {
10: static int m_count;
11: static int m_beforeCount;
12: static int m_afterCount;
13:
14: @BeforeClass
15: public void beforeClass() {
16: m_count = 0;
17: m_beforeCount = -1;
18: m_afterCount = -1;
19: }
20:
21: @BeforeMethod(firstTimeOnly=true)
22: public void beforeMethod() {
23: m_beforeCount = m_count;
24: }
25:
26: @Test(invocationCount=10)
27: public void f() {
28: m_count++;
29: }
30:
31: @AfterMethod(lastTimeOnly=true)
32: public void afterMethod() {
33: m_afterCount = m_count;
34: }
35: }
|