Reputation: 1491
I have a question about testng.
I have something like:
@Test
public initializeMethod() {
//here I do something that is needed before my real test method
}
@Test (depends on initializeMethod)
public myRealTest1{
//my test 1
}
@Test (depends on myRealTest1)
public myRealTest2{
//my test 2
}
Is it possible to skip initializeMethod in testng report (I mean that in report I want to see real count of tests (2 but not 3))?
Upvotes: 1
Views: 1372
Reputation: 5082
@Test
annotation is used specifically for the tests. You have to annotate the method initializeMethod()
properly with a non-test annotation. Several options are:
@BeforeTest
@BeforeClass
Other possible annotations:
@BeforeSuite
@BeforeGroups
@BeforeMethod // if you want `initializeMethod()` run before every test.
Upvotes: 1
Reputation: 37816
If you want to run initializeMethod() before each real Test method, you can use @BeforeMethod annotation. @BeforeMethod: The annotated method will be run before each test method. So, you need to declare the method as below:
@BeforeMethod
public initializeMethod() {
//here I do something that is needed before my real test method
}
If you want to run initializeMethod() only once, you can use @BeforeClass annotation. @BeforeClass: The annotated method will be run before the first test method in the current class is invoked. So, you need to declare the method as below:
@BeforeClass
public initializeMethod() {
//here I do something that is needed before my real test method
}
Upvotes: 1