Skip to main content

Posts

Showing posts with the label TestNG

TestNG MCQ

Question :What is TestNG? A programming language A test automation framework A browser An operating system Correct Answer :  A test automation framework   Question :Which file is used to configure TestNG settings? testng.properties testng.xml testng.cfg testng.settings Correct Answer :  testng.xml   Question :How do you define a test method in TestNG? public void testMethod()` public void testMethod()` with `@Test` annotation public void testMethod()` with `@startTest` annotation `@TestMethod` Correct Answer :  public void testMethod()` with `@Test` annotation   Question :What is the purpose of the `@Test` annotation in TestNG? It marks a method as a test method It defines the test data It specifies the test priority It handles test dependencies Correct Answer :  It marks a method as a test method   Question :How do you group test methods in TestNG? Using the `@Group` annotation Using the `@Test` annotation Using the `@Group` annotation with the group name Using the `@Test` annotation

TestNG Questions

Question:  TestNG Annotations Answer: @Test @BeforeMethod @AfterMethod @BeforeTest @AfterTest @BeforeClass @AfterClass @Test(enabled = false) @Test(enabled = true) @Test(priority=2) @Test(priority=5,dependsOnMethods={"method1","method2"}) @Test(dependsOnMethods = {"method1"}, alwaysRun=true) @Test(groups = { "Group1", "Group2" }) @Parameters({"testparameter1", "testparameter2"}) @Listeners(packagename.ListenerClassName.class) @Test (dataProvider = "getUserIDandPassword") @Test (description = "Open Facebook Login Page", timeOut=35000) @Test (invocationCount = 3, invocationTimeOut = 20000) @Test (invocationCount = 3, skipFailedInvocations = true) @Test (invocationCount = 3) @Test (invocationCount = 7, threadPoolSize = 2) Question:  Order of TestNG annotations Answer:  Order of TestNG annotations is as below : - @BeforeSuite @BeforeTest @BeforeClass @BeforeMethod @Test @AfterMethod @AfterClass @After