The document discusses 20 common TestNG interview questions for SDET roles. It covers topics like what TestNG is, advantages over JUnit, uses of testng.xml file, different annotations, execution sequence, dependencies, parameters, data providers, listeners, parallel execution, exception handling and more. The document aims to help candidates prepare for TestNG questions that may be asked during interviews for SDET positions.
IT Talk in Odessa for QA Automation/SDET engineers on 26/12/2016:
https://dou.ua/calendar/13626/
https://dataart.ru/events/odessa/it-talk-odessa-testng-vs-junit/
JUnit 4 code on github: https://github.com/a-oleynik/junit-workshop/tree/junit-4.13.2
TestNG code on github: https://github.com/a-oleynik/testng-workshop
Webinar on youtube (it was the next version but only a few slides and details were added): https://www.youtube.com/watch?v=3C-Nu5mkyOQ&t=3189
Test driven development - JUnit basics and best practicesNarendra Pathai
A presentation covering all the basics of Software Unit testing using JUnit framework. A lot of best practices, myths misconceptions are covered. Naming conventions for test methods and fundamental requirements for doing sustainable Junit testing.
IT Talk in Odessa for QA Automation/SDET engineers on 26/12/2016:
https://dou.ua/calendar/13626/
https://dataart.ru/events/odessa/it-talk-odessa-testng-vs-junit/
JUnit 4 code on github: https://github.com/a-oleynik/junit-workshop/tree/junit-4.13.2
TestNG code on github: https://github.com/a-oleynik/testng-workshop
Webinar on youtube (it was the next version but only a few slides and details were added): https://www.youtube.com/watch?v=3C-Nu5mkyOQ&t=3189
Test driven development - JUnit basics and best practicesNarendra Pathai
A presentation covering all the basics of Software Unit testing using JUnit framework. A lot of best practices, myths misconceptions are covered. Naming conventions for test methods and fundamental requirements for doing sustainable Junit testing.
Introduction of TestNG framework and its benefits over Junit frameworkBugRaptors
TestNG is a testing framework stirred from NUnit and JUnit but presenting some new functionalities that make it much easier and powerful to use. It is an open source automated testing framework; in which NG means Next Generation. TestNG is much more influential than JUnit but is inspired by JUnit. It is developed to be better than JUnit, specifically while testing integrated classes. We should thank Cedric Beust who has created TestNG.
TestNG is a testing framework inspired from JUnit and NUnit, which can be used as a core unit test framework for Java project.
Demo: https://github.com/bethmi/testng-demo
All software operates on data. High quality software needs to be thoroughly tested. This mandates to take the data into account and creates a need for easy and powerful solutions for data driven unit, functional and integration tests. Data driven tests are tests in which the test logic stays the same and the test data changes with each invocation of the test logic.
With TestNG implementing and executing data driven tests is easy as test data can be injected into test methods as method parameters. Unfortunately TestNG doesn't provide any standard for binding test data from external data sources, like XML, or CSV / Excel files, to the test method parameters. It rather leaves it up to each developer to implement her own solution for data binding. To minimize the effort this calls for the provision of a standardized solution.
This presentation shows how easy it is to implement data driven tests with TestNG. It then goes on to introduce the TestNG Data Binding framework. This framework fills the gap and provides a standardized solution for test data binding. It features an open, plug-in based architecture allowing for countless data formats to be bound to test method parameters. Currently it can bind data from CSV, Java .properties, text and XML files.
What is TestNG in Selenium? TestNG is a data driven framework that allows to group, prioritise and order your test case in the most convenient manner YOU descire. Let's see more about it.
Detailed comparison TestNG 6 and JUnit 4 for Integration, System and Acceptance testing levels. Everything needed by QA automation/SDET team. IT Talk was in Wroclaw on 30/03/2017. https://crossweb.pl/wydarzenia/qa-talk-test-analyze-manage-marzec-2017
JUnit 4 code on github: https://github.com/a-oleynik/junit-workshop/tree/junit-4.13.2
TestNG code on github: https://github.com/a-oleynik/testng-workshop
Webinar on youtube: https://www.youtube.com/watch?v=3C-Nu5mkyOQ&t=3189
1. Introduction to TestNG Framework.
2. TestNG Advantages.
3. Installation of Eclipse Plugin for TestNG.
4. The First Program using TestNG framework
5. TestNG Test Annotations and their uses
6. Execution of test case with a single class and with multiple class
7. Sequential and Parallel Run of Test Scripts
8. Verification of Test Result
Testing Experience - Evolution of Test Automation FrameworksŁukasz Morawski
Implementing automated tests is something that everybody wants to do. If you ask
any tester, test automation is their aim. And while it may be the golden target, very
few testers take pains to assess the required knowledge, under the illusion that a
programming language or expensive tool will suffice to cope with all problems likely
to arise. This is not true. Writing good automated tests is much harder than that,
requiring knowledge this article will make clear
Introduction of TestNG framework and its benefits over Junit frameworkBugRaptors
TestNG is a testing framework stirred from NUnit and JUnit but presenting some new functionalities that make it much easier and powerful to use. It is an open source automated testing framework; in which NG means Next Generation. TestNG is much more influential than JUnit but is inspired by JUnit. It is developed to be better than JUnit, specifically while testing integrated classes. We should thank Cedric Beust who has created TestNG.
TestNG is a testing framework inspired from JUnit and NUnit, which can be used as a core unit test framework for Java project.
Demo: https://github.com/bethmi/testng-demo
All software operates on data. High quality software needs to be thoroughly tested. This mandates to take the data into account and creates a need for easy and powerful solutions for data driven unit, functional and integration tests. Data driven tests are tests in which the test logic stays the same and the test data changes with each invocation of the test logic.
With TestNG implementing and executing data driven tests is easy as test data can be injected into test methods as method parameters. Unfortunately TestNG doesn't provide any standard for binding test data from external data sources, like XML, or CSV / Excel files, to the test method parameters. It rather leaves it up to each developer to implement her own solution for data binding. To minimize the effort this calls for the provision of a standardized solution.
This presentation shows how easy it is to implement data driven tests with TestNG. It then goes on to introduce the TestNG Data Binding framework. This framework fills the gap and provides a standardized solution for test data binding. It features an open, plug-in based architecture allowing for countless data formats to be bound to test method parameters. Currently it can bind data from CSV, Java .properties, text and XML files.
What is TestNG in Selenium? TestNG is a data driven framework that allows to group, prioritise and order your test case in the most convenient manner YOU descire. Let's see more about it.
Detailed comparison TestNG 6 and JUnit 4 for Integration, System and Acceptance testing levels. Everything needed by QA automation/SDET team. IT Talk was in Wroclaw on 30/03/2017. https://crossweb.pl/wydarzenia/qa-talk-test-analyze-manage-marzec-2017
JUnit 4 code on github: https://github.com/a-oleynik/junit-workshop/tree/junit-4.13.2
TestNG code on github: https://github.com/a-oleynik/testng-workshop
Webinar on youtube: https://www.youtube.com/watch?v=3C-Nu5mkyOQ&t=3189
1. Introduction to TestNG Framework.
2. TestNG Advantages.
3. Installation of Eclipse Plugin for TestNG.
4. The First Program using TestNG framework
5. TestNG Test Annotations and their uses
6. Execution of test case with a single class and with multiple class
7. Sequential and Parallel Run of Test Scripts
8. Verification of Test Result
Testing Experience - Evolution of Test Automation FrameworksŁukasz Morawski
Implementing automated tests is something that everybody wants to do. If you ask
any tester, test automation is their aim. And while it may be the golden target, very
few testers take pains to assess the required knowledge, under the illusion that a
programming language or expensive tool will suffice to cope with all problems likely
to arise. This is not true. Writing good automated tests is much harder than that,
requiring knowledge this article will make clear
What needs to consider to write effective unit test cases. Common mistakes developer do and how to overcome those with some basic understanding of unit test case writing.
JUnit: A unit testing framework that is extensively used to test the code written in Java.
Unit testing is a type of software testing.
Software testing: The process of examining whether the software and its components meet the specified requirements
Other types of software testing are as shown.
Ever tried doing Test First Test Driven Development? Ever failed? TDD is not easy to get right. Here's some practical advice on doing BDD and TDD correctly. This presentation attempts to explain to you why, what, and how you should test, tell you about the FIRST principles of tests, the connections of unit testing and the SOLID principles, writing testable code, test doubles, the AAA of unit testing, and some practical ideas about structuring tests.
Test Driven Development, or TDD, is the mainstream in many areas of software development, but what about the database? In this session, we explore TDD, the benefits of automated testing, and how testing data projects differs from other types of development. We introduce the tSQLt testing framework and demonstrate its use with a live coding example. Finally, we will discuss some lessons learned in doing TDD with SQL Server.
Originally presented by Steve Fibich and David Moore at Richmond SQL Server Users Group on January 11, 2018
Acetabularia Information For Class 9 .docxvaibhavrinwa19
Acetabularia acetabulum is a single-celled green alga that in its vegetative state is morphologically differentiated into a basal rhizoid and an axially elongated stalk, which bears whorls of branching hairs. The single diploid nucleus resides in the rhizoid.
How to Make a Field invisible in Odoo 17Celine George
It is possible to hide or invisible some fields in odoo. Commonly using “invisible” attribute in the field definition to invisible the fields. This slide will show how to make a field invisible in odoo 17.
Operation “Blue Star” is the only event in the history of Independent India where the state went into war with its own people. Even after about 40 years it is not clear if it was culmination of states anger over people of the region, a political game of power or start of dictatorial chapter in the democratic setup.
The people of Punjab felt alienated from main stream due to denial of their just demands during a long democratic struggle since independence. As it happen all over the word, it led to militant struggle with great loss of lives of military, police and civilian personnel. Killing of Indira Gandhi and massacre of innocent Sikhs in Delhi and other India cities was also associated with this movement.
June 3, 2024 Anti-Semitism Letter Sent to MIT President Kornbluth and MIT Cor...Levi Shapiro
Letter from the Congress of the United States regarding Anti-Semitism sent June 3rd to MIT President Sally Kornbluth, MIT Corp Chair, Mark Gorenberg
Dear Dr. Kornbluth and Mr. Gorenberg,
The US House of Representatives is deeply concerned by ongoing and pervasive acts of antisemitic
harassment and intimidation at the Massachusetts Institute of Technology (MIT). Failing to act decisively to ensure a safe learning environment for all students would be a grave dereliction of your responsibilities as President of MIT and Chair of the MIT Corporation.
This Congress will not stand idly by and allow an environment hostile to Jewish students to persist. The House believes that your institution is in violation of Title VI of the Civil Rights Act, and the inability or
unwillingness to rectify this violation through action requires accountability.
Postsecondary education is a unique opportunity for students to learn and have their ideas and beliefs challenged. However, universities receiving hundreds of millions of federal funds annually have denied
students that opportunity and have been hijacked to become venues for the promotion of terrorism, antisemitic harassment and intimidation, unlawful encampments, and in some cases, assaults and riots.
The House of Representatives will not countenance the use of federal funds to indoctrinate students into hateful, antisemitic, anti-American supporters of terrorism. Investigations into campus antisemitism by the Committee on Education and the Workforce and the Committee on Ways and Means have been expanded into a Congress-wide probe across all relevant jurisdictions to address this national crisis. The undersigned Committees will conduct oversight into the use of federal funds at MIT and its learning environment under authorities granted to each Committee.
• The Committee on Education and the Workforce has been investigating your institution since December 7, 2023. The Committee has broad jurisdiction over postsecondary education, including its compliance with Title VI of the Civil Rights Act, campus safety concerns over disruptions to the learning environment, and the awarding of federal student aid under the Higher Education Act.
• The Committee on Oversight and Accountability is investigating the sources of funding and other support flowing to groups espousing pro-Hamas propaganda and engaged in antisemitic harassment and intimidation of students. The Committee on Oversight and Accountability is the principal oversight committee of the US House of Representatives and has broad authority to investigate “any matter” at “any time” under House Rule X.
• The Committee on Ways and Means has been investigating several universities since November 15, 2023, when the Committee held a hearing entitled From Ivory Towers to Dark Corners: Investigating the Nexus Between Antisemitism, Tax-Exempt Universities, and Terror Financing. The Committee followed the hearing with letters to those institutions on January 10, 202
Read| The latest issue of The Challenger is here! We are thrilled to announce that our school paper has qualified for the NATIONAL SCHOOLS PRESS CONFERENCE (NSPC) 2024. Thank you for your unwavering support and trust. Dive into the stories that made us stand out!
Francesca Gottschalk - How can education support child empowerment.pptxEduSkills OECD
Francesca Gottschalk from the OECD’s Centre for Educational Research and Innovation presents at the Ask an Expert Webinar: How can education support child empowerment?
Embracing GenAI - A Strategic ImperativePeter Windle
Artificial Intelligence (AI) technologies such as Generative AI, Image Generators and Large Language Models have had a dramatic impact on teaching, learning and assessment over the past 18 months. The most immediate threat AI posed was to Academic Integrity with Higher Education Institutes (HEIs) focusing their efforts on combating the use of GenAI in assessment. Guidelines were developed for staff and students, policies put in place too. Innovative educators have forged paths in the use of Generative AI for teaching, learning and assessments leading to pockets of transformation springing up across HEIs, often with little or no top-down guidance, support or direction.
This Gasta posits a strategic approach to integrating AI into HEIs to prepare staff, students and the curriculum for an evolving world and workplace. We will highlight the advantages of working with these technologies beyond the realm of teaching, learning and assessment by considering prompt engineering skills, industry impact, curriculum changes, and the need for staff upskilling. In contrast, not engaging strategically with Generative AI poses risks, including falling behind peers, missed opportunities and failing to ensure our graduates remain employable. The rapid evolution of AI technologies necessitates a proactive and strategic approach if we are to remain relevant.
Welcome to TechSoup New Member Orientation and Q&A (May 2024).pdfTechSoup
In this webinar you will learn how your organization can access TechSoup's wide variety of product discount and donation programs. From hardware to software, we'll give you a tour of the tools available to help your nonprofit with productivity, collaboration, financial management, donor tracking, security, and more.
Welcome to TechSoup New Member Orientation and Q&A (May 2024).pdf
Dev labs alliance top 20 testng interview questions for sdet
1. Top 20 TestNG Interview Questions
for SDET
By DevLabs Alliance
Visit us at:
www.devlabsalliance.com
Email:
training@devlabsalliance.com
Contact: +91 9717514555
2. TestNG Interview Questions for SDET
1. What is TestNG?
TestNG is a testing framework used for executing the unit tests in Java.
TestNG is an automated open source testing framework that can be integrated with
Selenium and capable of making Selenium tests easier to understand and provide multiple
capabilities like assertion, report generation, parallel test execution, etc.
It is inspired by JUnit. It has all the features of JUnit and has its own new features which
makes it more powerful.
Full form of TestNG is “Testing Next Generation”.
3. TestNG Interview Questions for SDET
2. What are the advantages of TestNG over JUnit?
The advantages of TestNG over JUnit are:
• TestNG Annotations are easier to use and understand.
• Test Cases in TestNG can be grouped more easily.
• TestNG provides feature to create and execute parallel tests.
• TestNG is used to create detailed HTML reports.
• TestNG allows to define dependency of one test method over other method.
• TestNG allows to assign priority to test cases.
4. TestNG Interview Questions for SDET
3. What is the use of testng.xml file?
Testng.xml is used for configuring the whole test suite. The various uses of TestNG are as
follows:
• All the tests in the test suite are triggered by testing.xml
• It is used to pass parameters to test scripts.
• It is used to support inclusion and exclusion of tests.
• It is used to create the test groups.
• It supports the parallel execution of test cases.
5. TestNG Interview Questions for SDET
4. What are the different annotations available in TestNG?
The different annotations of TestNG are:
• @BeforeTest
• @AfterTest
• @BeforeClass
• @AfterClass
• @BeforeMethod
• @AfterMethod
• @BeforeSuite
• @AfterSuite
• @BeforeGroups
• @AfterGroups
• @Test
6. TestNG Interview Questions for SDET
5. What is the sequence of execution of annotations in TestNG?
The sequence of execution of annotations is as follows:
• @BeforeSuite
• @BeforeTest
• @BeforeClass
• @BeforeMethod
• @Test
• @AfterMethod
• @AfterClass
• @AfterTest
• @AfterSuite
7. TestNG Interview Questions for SDET
6. How to create a xml file in TestNG?
To create xml file in TestNG, follow the following steps:
• Right click on Java project folder.
• Go to “New” and select “File” option.
• In New file wizard, specify file name as “testing.xml”.
• Click on Finish button.
This will add testing.xml file under Java project folder.
8. TestNG Interview Questions for SDET
7. What is a dependency in TestNG?
Dependency is used for some of the methods on which many methods are dependent on.
For eg.: For any application, if login page do not work, then it should not test the rest of
test scenarios.
In this case we would be using the LoginTest method on which other tests are dependent.
@Test(dependsOnMethods=“LoginTest”)
Public void SearchPage()
{
}
Since SearchPage is dependent on LoginTest method, so if LoginTest method fails, then
SearchPage method will not get executed.
9. TestNG Interview Questions for SDET
8. What is InvocationCount in TestNG?
InvocationCount is used to execute same test case multiple times.
For eg.:
@Test(invocationCount = 10)
Public void Login()
{
}
In this case, Login() method will execute 10 times.
10. TestNG Interview Questions for SDET
9. What is timeOut in TestNG?
If we want to terminate any method in the test script which is taking too much time to
execute, then we can use “timeOut” attributein TestNG.
Time is provided in miliseconds(ms)
For eg.:
@Test(timeOut = 2000)
Public void Login()
{
}
In this case, the Login() method will get terminated in 2000 ms (2 seconds) and the test
case gets Failed.
11. TestNG Interview Questions for SDET
10. What are common assertions in TestNG?
The common TestNG assertions are:
• Assert.assertEquals(string actual, string expected) :
If both the strings are equal, then only test case will pass.
• Assert.assertTrue(condition) :
It accepts a Boolean value. The assertion will pass if condition is True, otherwise it will
get fail.
• Assert.assertFalse(condition) :
It accepts a Boolean value. The assertion will pass if condition is False, otherwise it will
get fail.
12. TestNG Interview Questions for SDET
11. How a test can be disabled in TestNG?
To disable any test case in TestNG, we use “enabled” attribute.
For eg.:
@Test(enabled= “false”)
Public void LoginTest()
{
}
In this case, LoginTest() method will get disabled.
13. TestNG Interview Questions for SDET
12. What is assertion and what are the types of asserts in TestNG?
Assertion is used to validate the results of test cases.
There are two types of assertion:
• HardAssert: HardAssert is used to validate the test result. If hard assert fails, then none
of the code execution will take place after Assert statement.
Assert.assertEquals(actual value, expected value)
• Soft Assert: Soft Assert is also used to validate the test results but if soft assert fails,
then also execution of code will be continued for next statements.
To create a soft assert, object of “softAssert” class is created:
softAssert sAssert = new softAssert();
sAssert.assertAll();
14. TestNG Interview Questions for SDET
13. How to set test case priority in TestNG?
Priority attribute is used to set the order of execution of test cases.
If priority is not set then the test scripts are executed in alphabetical order.
For eg.:
Public class PriorityTestCase{
@Test(priority=0)
public void testCase1(){
system.out.println(“DLA Test Case 1”);
}
@Test(priority=1)
public void testCase2(){
system.out.println(“DLA Test Case 2”);
}
}
In this case, testCase1 will be executed first and then testCase2 will get execeuted.
15. TestNG Interview Questions for SDET
14. How can we pass parameter to test script using TestNG?
We can pass parameter to test scripts by using @Parameter annotation in test and
“parameter” tag in testing.xml.
Sample testing.xml:
<suite name = “dlaTestSuite”>
<test name = “dlaTest”>
<parameter name = “dlaParamName” value = “dlaParamValue”>
<classes>
<class name = “dlaTestFile” />
</classes> </test> </suite>
Sample Test Script:
public class dlaTestFile{
@Test
@Parameters(“dlaParamName”)
public void dlaParameterTest(string paramValue){
System.out.println(sampleParamName);
} }
16. TestNG Interview Questions for SDET
15. How can we create data driven framework using TestNG?
To create data driven framework, @DataProvider is used in which data is passed to the
associated test method and multiple iteration of tests run for different data values passed
from @DataProvider method.
For eg.:
@DataProvider(name = “dlaDataProvider”)
public Object[] [] dataProviderMethod() {
return new Object[] [] {{“dev”, “lab”}, {“devlabs”, “alliance”}};
}
@Test(dataProvider = “dlaDataProvider”)
public void dlaTest(string s1, string s2) {
system.out.println(s1 + “ “ + s2);
}
17. TestNG Interview Questions for SDET
16. What is the use of @Listener annotation in TestNG?
TestNG provides some kinds of listeners using which some actions can be performed in
case an event has triggered. Mostly TestNG listeners are used for configuration of reports
and logging.
The most widely used lisetner in TestNG is ITestListener interface. It contains methods like
onTestSuccess, onTestFailure, onTestSkipped etc. To implement this interface, we have to
create a listener class of our own. After that @Listener annotation is used to specify that
for a particular test class our customized listener class should be used.
For eg.:
@Listeners(PackageName.CustomizedListenerClassName.class)
public class dlaTestClass {
WebDriver driver = new FirefoxDriver();
@Test
public void dlaTestMethod(){
//test logic
}}
18. TestNG Interview Questions for SDET
17. What is the difference between @Factory and @DataProvider
annotation?
@Factory method creates instances of test class and run all the test methods in that class
with different set of data.
@DataProvider is bound to individual test methods and run the specific methods multiple
times.
19. TestNG Interview Questions for SDET
18. How can we run test cases in parallel using TestNG?
To run the tests in parallel in TestNG, we have to add these two key value pairs in suite-
• Parallel = "{methods/tests/classes}“
• thread-count= "{number of thread you want to run simultaneously}“
For eg.:
<suite name = “DLATestSuite” parallel = “methods” thread-count = “5”>
20. TestNG Interview Questions for SDET
19. How can we make sure a test method runs even if the test methods
or groups on which it depends fail or get skipped?
To run the test method even if test methods or groups on which it depends get fail or
skipped, we use “alwaysRun” attribute of @Test annotation.
For eg.:
@Test
public void parentTest() {
Assert.Fail(“Failed Test”);
}
@Test(dependsOnMethods = {“parentTest”}, alwaysRun = true)
Public void DependentTest() {
System.out.println(“Test DLA”);
}
21. TestNG Interview Questions for SDET
20. How to handle exceptions in TestNG?
To handle exception in methods we can mention the exception in @Test annotation so
that the test case does not fail.
For eg.: If a test method is expected to have “numberFormatException” exception, then
the test case will fail because of this exception if no try catch block is specified.
But this can be handled in TestNG by using “expectedException” attribute:
@Test(expectedException=numberFormatException.class)
After this the test case will run without failing.
22. Visit us at: www.devlabsalliance.com
Email: training@devlabsalliance.com
Contact: +91 9717514555