1. What are the annotations
used in TestNG ?
·
@Test, @BeforeSuite,
@AfterSuite, @BeforeTest, @AfterTest, @BeforeClass, @AfterClass, @BeforeMethod,
@AfterMethod.
2. What is the difference
between @BeforeMethod and @BeforeClass ?
·
@BeforeMethod- this will
execute before every @Test method.
·
@BeforeClass- this will execute
before every class.
3. What are the different
attributes for @Test annotation?
·
alwaysRun, dataProvider,
dependsOnMethods, enabled, priority etc.
4. What is return type of
Data Provider?
·
Object[][]
5. What are advantages of
TestNG over Junit?
·
In Junit we have to declare
@BeforeClass and @AfterClass which is a constraint where as in TestNG there is
no constraint like this.
·
Additional Levels of
setUp/tearDown level are available in TestNG like
@Before/AfterSuite,@Before/AfterTest and @Before/AfterGroup
·
No Need to extend any class in
TestNG.
·
There is no method name
constraint in TestNG as in Junit. You can give any name to the test methods in
TestNG
·
In TestNG we can tell the test
that one method is dependent on another method where as in Junit this is not
possible. In Junit each test is independent of another test.
·
Grouping of test cases is
available in TestNGwhere as the same is not available in Junit.
·
Execution can be done based on
Groups..
·
Also using TestNG your selenium
testcase execution can be done in parallel
6. I'm running testng.xml
with group name. Before/AfterClass is not running?
·
When you specify a group to
run, any method that is not part of this group will not be run. Since @BeforeClass/@AfterClass do not belong
to that group, they are not being run.
·
The way to fix this is to put
these methods in that group or to use alwaysRun=true
7. What is the difference
between priority and dependsOnMethods?
·
Priority is used set the
sequence of execution of @Test mthods in a TestNg class
·
dependsOnMethods is used to
skip test methods whenever dependent method is failed/skipped.
No comments:
Post a Comment