SlideShare a Scribd company logo
1 of 22
Top 20 JUnit Interview Questions for
SDET
By DevLabs Alliance
Visit us at: www.devlabsalliance.com
Email: training@devlabsalliance.com
Contact: +91 9717514555
JUnit Interview Questions for SDET
1. What is JUnit?
JUnit is a regression testing framework which is used for performing Unit Testing of Java
code.
It is an open source software managed by JUnit.org community.
JUnit = Java + Unit Testing
JUnit Interview Questions for SDET
2. What are the important features of JUnit?
The important features of JUnit are:
• It is an open source framework.
• It provides various annotations to identify the test methods.
• It provides test runners for running tests.
• It provides assertions to test the expected results.
• It shows test progress in a bar. If test goes fine, then it shows green and when test fails,
it turns to red.
• It can be organized into test suites that contains test cases and other test suites as well.
JUnit Interview Questions for SDET
3. What are the core features of JUnit?
JUnit framework provides following features:
• Fixtures
• Test Suites
• Test Runners
• JUnit Classes
JUnit Interview Questions for SDET
4. What are JUnit classes? List some of JUnit classes.
JUnit classes are important classes that are used in writing and testing JUnit programs.
Some of the important JUnit classes are:
• Assert: Contains a set of Assert methods.
• TestCase: Contains a test case that defines the fixture to run multiple tests.
• TestResult: Contains a method that collects the results after execution of test case.
• TestSuite: It is a composition of Junit tests.
JUnit Interview Questions for SDET
5. What is a Fixture in JUnit?
A test fixture in JUnit is defined as a fixed state of some set of objects which are used as a
baseline for running tests.
The main objective of a test fixture is to ensure that there is some known and fixed
environment in which tests are run so that results are repeatable.
It basically includes the following methods:
• setUp() method which runs before every test methods.
• tearDown() method which runs after every test methods.
JUnit Interview Questions for SDET
6. What are JUnit annotations and how are they useful in JUnit?
JUnit annotations are like meta-tags that can be added to our code and we can apply them
to methods or in class.
Annotations are very useful in JUnit as they give the information about test methods that
which methods are going to run before test methods or which methods are going to run
after test methods. It also gives the information that which method or class will be ignored
during execution.
JUnit Interview Questions for SDET
7. What are the important JUnit annotations?
The important JUnit annotations are as follows:
• @Test: The Test annotation tells that this is the test method which will run first unless
specified.
• @BeforeClass: The method with @BeforeClass annotation specifies that it should be
run once before any of the Test method in class.
• @Before: The method with @Before annotation specifies that it should be run before
each test method.
• @After: The method with @After annotation specifies that it should be run after the
test method.
• @AfterClass: This method with @AfterClass annotation specifies that it should be run
after all tests have finished. This can be used for performing clean-up activities.
JUnit Interview Questions for SDET
8. What is @ignore annotation in JUnit and how is this useful?
@Ignore annotation is used to ignore that particular tests or group of tests so that build
failure can be skipped.
@Ignore annotation is very useful when there are cases when we can’t fix a code that is
failing but still we want that method to be around so that it does not get forgotten and we
can fix them later.
Also it is very easy to identify all @Ignore annotation rather than finding the comment out
test cases.
JUnit Interview Questions for SDET
9. What are Parameterized tests in JUnit and what are the annotations
used for this?
Parameterized Tests allow developers to pass parameters into their test classes and hence
allowing him to run the same test again and again using different values.
Annotations used for Parameterization are:
• @RunWith(Parameterized.Class) – To make a class parameterized.
• @Parameters – Parameterized class must have a static method with @Parameter
annotation that returns a collection of array as test data set.
JUnit Interview Questions for SDET
10. Can we change return type of JUnit test method from void to some
other type?
Ideally, we should not change the return type of JUnit test from void to some other type.
All the methods of JUnit tests should have a void return type.
If we change the return type from void to some other type, then the test method would
not be considered as a test method and would be ignored during execution of tests.
JUnit Interview Questions for SDET
11. Name the tools with which JUnit can be easily integrated.
JUnit can be easily integrated with following tools:
• Eclipse
• Ant
• Maven
JUnit Interview Questions for SDET
12. Name some JUnit extensions.
Following are some of the JUnit extensions:
• Cactus
• JWebUnit
• XMLUnit
• MockObject
JUnit Interview Questions for SDET
13. What are Cactus extensions and what are its common components?
Cactus is a testing framework that is used for unit testing server-side java code such as
Servlets, EJBs and Tag Libs.
The intent of Cactus is to minimize the cost of writing tests for server-side code. It uses
JUnit internally and extend it. Cactus implements an in-container strategy which means
that the all the tests are executed inside the container.
The components of cactus are:
• Cactus framework is the core of Cactus. It provides the API to write Cactus tests.
• Cactus Integration Modules are other components and they are front ends and
frameworks that provide the easy way of using the Cactus framework like Ant Scripts,
Eclipse plugin or Maven plugin.
JUnit Interview Questions for SDET
14. What is JWebUnit and what are its advantages?
WebUnit is a Java-based testing framework to test web applications. It wraps existing
testing frameworks like Selenium and HtmlUnit with a simple, unified testing interface ans
that allow us to quickly test the correctness of web applications.
The various advantages of JWebUnit are as follows:
• It provides a high-level Java API which is used for navigating a web-application with a
set of assertions to verify the correctness of application.
• This API includes form entry and submission, navigation via link, validation of table
contents and other typical business web application features.
• The ready to use assertions and simple navigation is helpful for more rapid test
creation.
JUnit Interview Questions for SDET
15. What is XMLUnit and what is the use of supporting classes in
XMLUnit?
XMLUnit is used for providing a single JUnit extension class, XMLTestCase and a set of
supporting classes.
Supporting classes in XMLUnit allow assertions to be made about:
• Differences between 2 pieces of XML through Diff and DetailedDiff classes.
• Validation of a piece of XML through Validator class.
• The result of transforming a piece of XML using XSLT through transform class.
• The evaluation of XPath expression on a piece of XML through XPath engine interface.
• Individual nodes in a piece of XML that are exposed by Dom traversal through NodeTest
class.
JUnit Interview Questions for SDET
16. Why does JUnit only report the first failure in a single test?
Reporting multiple failures in a single test implies that the test is doing too much and it is
too big a unit test.
So, JUnit is designed in such a way that it works best with a number of small tests.
It executes each test within a separate instance of test class and reports failure on each
test.
JUnit Interview Questions for SDET
17. How can we run JUnit from command window?
To run JUnit from command window, we have to follow the following steps:
• Set the ClassPath:
set CLASSPATH = %CLASSPATH%;%JUNIT_HOME%junit.jar
• Invoke JUnit runner :
java org.junit.runner.JUnitCore
JUnit Interview Questions for SDET
18. Mention different methods of exception handling in JUnit.
The different methods of Exception handling in JUnit are as follows:
• Try catch statement
• With @Test annotation
• With catch exception library
• With JUnit rule
• With custom annotation
JUnit Interview Questions for SDET
19. Mention best practices to write a unit test case in JUnit.
The various best practices to be followed while writing a unit test in JUnit are as follows:
• A well-written test case is the one that has a known input and expected output, which
is computed before the execution of test.
• A known input should always test a pre-condition and the expected output should
always verify a post-condition.
• It is always recommended to have atleast 2 unit test cases for each requirement, one of
them is positive test and the other one is for negative test.
• If any requirement have sub-requirements, then it should also have atleast 2 unit test
cases as positive and negative tests.
JUnit Interview Questions for SDET
20. Mention the differences between JUnit and TestNG.
JUnit TestNG
The naming convention for JUnit
annotation is a bit complicated like
“Before”, “After” and “Expected”.
The naming convention of TestNG are
easier to understand like “BeforMethod”,
“AfterMethod”, etc.
Grouping of test cases are not available in
JUnit.
Grouping of test cases is possible in
TestNG.
JUnit framework do not have
“Dependency Test” feature.
TestNG use “dependsOnMethods” to
implement the dependency testing.
JUnit does not support parallel execution
of Selenium test cases.
Parallel execution of Selenium test case is
possible in TestNG.
JUnit cannot re-run the failed tests. TestNG can re-run the failed tests.
Visit us at: www.devlabsalliance.com
Email: training@devlabsalliance.com
Contact: +91 9717514555

More Related Content

What's hot

Journey's diary developing a framework using tdd
Journey's diary   developing a framework using tddJourney's diary   developing a framework using tdd
Journey's diary developing a framework using tddeduardomg23
 
Lulu.com.java.j2 ee.job.interview.companion.2nd.edition.apr.2007
Lulu.com.java.j2 ee.job.interview.companion.2nd.edition.apr.2007Lulu.com.java.j2 ee.job.interview.companion.2nd.edition.apr.2007
Lulu.com.java.j2 ee.job.interview.companion.2nd.edition.apr.2007Arun Kumar
 
201 core java interview questions oo ps interview questions - javatpoint
201 core java interview questions   oo ps interview questions - javatpoint201 core java interview questions   oo ps interview questions - javatpoint
201 core java interview questions oo ps interview questions - javatpointravi tyagi
 
Java/J2EE interview Qestions
Java/J2EE interview QestionsJava/J2EE interview Qestions
Java/J2EE interview QestionsArun Vasanth
 
Realtime selenium interview questions
Realtime selenium interview questionsRealtime selenium interview questions
Realtime selenium interview questionsKuldeep Pawar
 
Unit Testing & TDD Training for Mobile Apps
Unit Testing & TDD Training for Mobile AppsUnit Testing & TDD Training for Mobile Apps
Unit Testing & TDD Training for Mobile AppsMarcelo Busico
 
Java design pattern tutorial
Java design pattern tutorialJava design pattern tutorial
Java design pattern tutorialAshoka Vanjare
 
Class notes(week 9) on multithreading
Class notes(week 9) on multithreadingClass notes(week 9) on multithreading
Class notes(week 9) on multithreadingKuntal Bhowmick
 
Clean Unit Test Patterns
Clean Unit Test PatternsClean Unit Test Patterns
Clean Unit Test PatternsFrank Appel
 
Unit Tests And Automated Testing
Unit Tests And Automated TestingUnit Tests And Automated Testing
Unit Tests And Automated TestingLee Englestone
 
50+ java interview questions
50+ java interview questions50+ java interview questions
50+ java interview questionsSynergisticMedia
 
Test driven development in .Net - 2010 + Eclipse
Test driven development in .Net - 2010 + EclipseTest driven development in .Net - 2010 + Eclipse
Test driven development in .Net - 2010 + EclipseUTC Fire & Security
 
Xp Day 080506 Unit Tests And Mocks
Xp Day 080506 Unit Tests And MocksXp Day 080506 Unit Tests And Mocks
Xp Day 080506 Unit Tests And Mocksguillaumecarre
 
Extreme Interview Questions
Extreme Interview QuestionsExtreme Interview Questions
Extreme Interview QuestionsEhtisham Ali
 
Working With Legacy Code
Working With Legacy CodeWorking With Legacy Code
Working With Legacy CodeAndrea Polci
 

What's hot (20)

Java interview question
Java interview questionJava interview question
Java interview question
 
Journey's diary developing a framework using tdd
Journey's diary   developing a framework using tddJourney's diary   developing a framework using tdd
Journey's diary developing a framework using tdd
 
Lulu.com.java.j2 ee.job.interview.companion.2nd.edition.apr.2007
Lulu.com.java.j2 ee.job.interview.companion.2nd.edition.apr.2007Lulu.com.java.j2 ee.job.interview.companion.2nd.edition.apr.2007
Lulu.com.java.j2 ee.job.interview.companion.2nd.edition.apr.2007
 
201 core java interview questions oo ps interview questions - javatpoint
201 core java interview questions   oo ps interview questions - javatpoint201 core java interview questions   oo ps interview questions - javatpoint
201 core java interview questions oo ps interview questions - javatpoint
 
Java/J2EE interview Qestions
Java/J2EE interview QestionsJava/J2EE interview Qestions
Java/J2EE interview Qestions
 
Java scjp-part1
Java scjp-part1Java scjp-part1
Java scjp-part1
 
Realtime selenium interview questions
Realtime selenium interview questionsRealtime selenium interview questions
Realtime selenium interview questions
 
Unit Testing & TDD Training for Mobile Apps
Unit Testing & TDD Training for Mobile AppsUnit Testing & TDD Training for Mobile Apps
Unit Testing & TDD Training for Mobile Apps
 
Java design pattern tutorial
Java design pattern tutorialJava design pattern tutorial
Java design pattern tutorial
 
Class notes(week 9) on multithreading
Class notes(week 9) on multithreadingClass notes(week 9) on multithreading
Class notes(week 9) on multithreading
 
Test Automation and Keyword-driven testing af Brian Nielsen, CISS/AAU
Test Automation and Keyword-driven testing af Brian Nielsen, CISS/AAUTest Automation and Keyword-driven testing af Brian Nielsen, CISS/AAU
Test Automation and Keyword-driven testing af Brian Nielsen, CISS/AAU
 
Clean Unit Test Patterns
Clean Unit Test PatternsClean Unit Test Patterns
Clean Unit Test Patterns
 
Unit Tests And Automated Testing
Unit Tests And Automated TestingUnit Tests And Automated Testing
Unit Tests And Automated Testing
 
50+ java interview questions
50+ java interview questions50+ java interview questions
50+ java interview questions
 
Unit Testing in Java
Unit Testing in JavaUnit Testing in Java
Unit Testing in Java
 
Test driven development in .Net - 2010 + Eclipse
Test driven development in .Net - 2010 + EclipseTest driven development in .Net - 2010 + Eclipse
Test driven development in .Net - 2010 + Eclipse
 
Xp Day 080506 Unit Tests And Mocks
Xp Day 080506 Unit Tests And MocksXp Day 080506 Unit Tests And Mocks
Xp Day 080506 Unit Tests And Mocks
 
Extreme Interview Questions
Extreme Interview QuestionsExtreme Interview Questions
Extreme Interview Questions
 
Working With Legacy Code
Working With Legacy CodeWorking With Legacy Code
Working With Legacy Code
 
Concurrency on the JVM
Concurrency on the JVMConcurrency on the JVM
Concurrency on the JVM
 

Similar to Top 20 Junit interview questions for sdet

Junit Interview Questions-ppt
Junit Interview Questions-pptJunit Interview Questions-ppt
Junit Interview Questions-pptMayank Kumar
 
JUnit- A Unit Testing Framework
JUnit- A Unit Testing FrameworkJUnit- A Unit Testing Framework
JUnit- A Unit Testing FrameworkOnkar Deshpande
 
Introduction To UnitTesting & JUnit
Introduction To UnitTesting & JUnitIntroduction To UnitTesting & JUnit
Introduction To UnitTesting & JUnitMindfire Solutions
 
JUnit with_mocking
JUnit with_mockingJUnit with_mocking
JUnit with_mockingZeeshan Khan
 
Test driven development and unit testing with examples in C++
Test driven development and unit testing with examples in C++Test driven development and unit testing with examples in C++
Test driven development and unit testing with examples in C++Hong Le Van
 
Introduction of TestNG framework and its benefits over Junit framework
Introduction of TestNG framework and its benefits over Junit frameworkIntroduction of TestNG framework and its benefits over Junit framework
Introduction of TestNG framework and its benefits over Junit frameworkBugRaptors
 
What is JUnit? | Edureka
What is JUnit? | EdurekaWhat is JUnit? | Edureka
What is JUnit? | EdurekaEdureka!
 
Unit Testing in .NET Core 7.0 with XUnit.pptx
Unit Testing in .NET Core 7.0 with XUnit.pptxUnit Testing in .NET Core 7.0 with XUnit.pptx
Unit Testing in .NET Core 7.0 with XUnit.pptxKnoldus Inc.
 
The Ultimate Guide to Java Testing Frameworks.pdf
The Ultimate Guide to Java Testing Frameworks.pdfThe Ultimate Guide to Java Testing Frameworks.pdf
The Ultimate Guide to Java Testing Frameworks.pdfUncodemy
 
TestNG introduction
TestNG introductionTestNG introduction
TestNG introductionDenis Bazhin
 
An insight to test driven development and unit testing
An insight to test driven development and unit testingAn insight to test driven development and unit testing
An insight to test driven development and unit testingDharmendra Prasad
 
JUnit is a Regression Testing Framework used by developers to implem.pdf
JUnit is a Regression Testing Framework used by developers to implem.pdfJUnit is a Regression Testing Framework used by developers to implem.pdf
JUnit is a Regression Testing Framework used by developers to implem.pdfaplolomedicalstoremr
 
5 Best Unit Test Frameworks to Automate Unit Tests
5 Best Unit Test Frameworks to Automate Unit Tests5 Best Unit Test Frameworks to Automate Unit Tests
5 Best Unit Test Frameworks to Automate Unit TestsSerena Gray
 
How To Use Ignore Annotation In JUnit
How To Use Ignore Annotation In JUnitHow To Use Ignore Annotation In JUnit
How To Use Ignore Annotation In JUnitBugRaptors
 
Unit Testing Frameworks: A comparative study
Unit Testing Frameworks: A comparative studyUnit Testing Frameworks: A comparative study
Unit Testing Frameworks: A comparative studyIRJET Journal
 

Similar to Top 20 Junit interview questions for sdet (20)

Junit Interview Questions-ppt
Junit Interview Questions-pptJunit Interview Questions-ppt
Junit Interview Questions-ppt
 
JUnit- A Unit Testing Framework
JUnit- A Unit Testing FrameworkJUnit- A Unit Testing Framework
JUnit- A Unit Testing Framework
 
Introduction To UnitTesting & JUnit
Introduction To UnitTesting & JUnitIntroduction To UnitTesting & JUnit
Introduction To UnitTesting & JUnit
 
JUnit with_mocking
JUnit with_mockingJUnit with_mocking
JUnit with_mocking
 
Test driven development and unit testing with examples in C++
Test driven development and unit testing with examples in C++Test driven development and unit testing with examples in C++
Test driven development and unit testing with examples in C++
 
Test NG Framework Complete Walk Through
Test NG Framework Complete Walk ThroughTest NG Framework Complete Walk Through
Test NG Framework Complete Walk Through
 
Introduction of TestNG framework and its benefits over Junit framework
Introduction of TestNG framework and its benefits over Junit frameworkIntroduction of TestNG framework and its benefits over Junit framework
Introduction of TestNG framework and its benefits over Junit framework
 
unit 1 (1).pptx
unit 1 (1).pptxunit 1 (1).pptx
unit 1 (1).pptx
 
What is JUnit? | Edureka
What is JUnit? | EdurekaWhat is JUnit? | Edureka
What is JUnit? | Edureka
 
Munit_in_mule_naveen
Munit_in_mule_naveenMunit_in_mule_naveen
Munit_in_mule_naveen
 
Unit Testing in .NET Core 7.0 with XUnit.pptx
Unit Testing in .NET Core 7.0 with XUnit.pptxUnit Testing in .NET Core 7.0 with XUnit.pptx
Unit Testing in .NET Core 7.0 with XUnit.pptx
 
The Ultimate Guide to Java Testing Frameworks.pdf
The Ultimate Guide to Java Testing Frameworks.pdfThe Ultimate Guide to Java Testing Frameworks.pdf
The Ultimate Guide to Java Testing Frameworks.pdf
 
TestNG introduction
TestNG introductionTestNG introduction
TestNG introduction
 
Chapter 7
Chapter 7Chapter 7
Chapter 7
 
An insight to test driven development and unit testing
An insight to test driven development and unit testingAn insight to test driven development and unit testing
An insight to test driven development and unit testing
 
JUnit is a Regression Testing Framework used by developers to implem.pdf
JUnit is a Regression Testing Framework used by developers to implem.pdfJUnit is a Regression Testing Framework used by developers to implem.pdf
JUnit is a Regression Testing Framework used by developers to implem.pdf
 
5 Best Unit Test Frameworks to Automate Unit Tests
5 Best Unit Test Frameworks to Automate Unit Tests5 Best Unit Test Frameworks to Automate Unit Tests
5 Best Unit Test Frameworks to Automate Unit Tests
 
How To Use Ignore Annotation In JUnit
How To Use Ignore Annotation In JUnitHow To Use Ignore Annotation In JUnit
How To Use Ignore Annotation In JUnit
 
TDD Workshop UTN 2012
TDD Workshop UTN 2012TDD Workshop UTN 2012
TDD Workshop UTN 2012
 
Unit Testing Frameworks: A comparative study
Unit Testing Frameworks: A comparative studyUnit Testing Frameworks: A comparative study
Unit Testing Frameworks: A comparative study
 

Recently uploaded

ODSC - Batch to Stream workshop - integration of Apache Spark, Cassandra, Pos...
ODSC - Batch to Stream workshop - integration of Apache Spark, Cassandra, Pos...ODSC - Batch to Stream workshop - integration of Apache Spark, Cassandra, Pos...
ODSC - Batch to Stream workshop - integration of Apache Spark, Cassandra, Pos...Christina Lin
 
Russian Call Girls in Karol Bagh Aasnvi ➡️ 8264348440 💋📞 Independent Escort S...
Russian Call Girls in Karol Bagh Aasnvi ➡️ 8264348440 💋📞 Independent Escort S...Russian Call Girls in Karol Bagh Aasnvi ➡️ 8264348440 💋📞 Independent Escort S...
Russian Call Girls in Karol Bagh Aasnvi ➡️ 8264348440 💋📞 Independent Escort S...soniya singh
 
Dealing with Cultural Dispersion — Stefano Lambiase — ICSE-SEIS 2024
Dealing with Cultural Dispersion — Stefano Lambiase — ICSE-SEIS 2024Dealing with Cultural Dispersion — Stefano Lambiase — ICSE-SEIS 2024
Dealing with Cultural Dispersion — Stefano Lambiase — ICSE-SEIS 2024StefanoLambiase
 
Unveiling Design Patterns: A Visual Guide with UML Diagrams
Unveiling Design Patterns: A Visual Guide with UML DiagramsUnveiling Design Patterns: A Visual Guide with UML Diagrams
Unveiling Design Patterns: A Visual Guide with UML DiagramsAhmed Mohamed
 
KnowAPIs-UnknownPerf-jaxMainz-2024 (1).pptx
KnowAPIs-UnknownPerf-jaxMainz-2024 (1).pptxKnowAPIs-UnknownPerf-jaxMainz-2024 (1).pptx
KnowAPIs-UnknownPerf-jaxMainz-2024 (1).pptxTier1 app
 
SuccessFactors 1H 2024 Release - Sneak-Peek by Deloitte Germany
SuccessFactors 1H 2024 Release - Sneak-Peek by Deloitte GermanySuccessFactors 1H 2024 Release - Sneak-Peek by Deloitte Germany
SuccessFactors 1H 2024 Release - Sneak-Peek by Deloitte GermanyChristoph Pohl
 
Open Source Summit NA 2024: Open Source Cloud Costs - OpenCost's Impact on En...
Open Source Summit NA 2024: Open Source Cloud Costs - OpenCost's Impact on En...Open Source Summit NA 2024: Open Source Cloud Costs - OpenCost's Impact on En...
Open Source Summit NA 2024: Open Source Cloud Costs - OpenCost's Impact on En...Matt Ray
 
Intelligent Home Wi-Fi Solutions | ThinkPalm
Intelligent Home Wi-Fi Solutions | ThinkPalmIntelligent Home Wi-Fi Solutions | ThinkPalm
Intelligent Home Wi-Fi Solutions | ThinkPalmSujith Sukumaran
 
MYjobs Presentation Django-based project
MYjobs Presentation Django-based projectMYjobs Presentation Django-based project
MYjobs Presentation Django-based projectAnoyGreter
 
Building a General PDE Solving Framework with Symbolic-Numeric Scientific Mac...
Building a General PDE Solving Framework with Symbolic-Numeric Scientific Mac...Building a General PDE Solving Framework with Symbolic-Numeric Scientific Mac...
Building a General PDE Solving Framework with Symbolic-Numeric Scientific Mac...stazi3110
 
Implementing Zero Trust strategy with Azure
Implementing Zero Trust strategy with AzureImplementing Zero Trust strategy with Azure
Implementing Zero Trust strategy with AzureDinusha Kumarasiri
 
Folding Cheat Sheet #4 - fourth in a series
Folding Cheat Sheet #4 - fourth in a seriesFolding Cheat Sheet #4 - fourth in a series
Folding Cheat Sheet #4 - fourth in a seriesPhilip Schwarz
 
Balasore Best It Company|| Top 10 IT Company || Balasore Software company Odisha
Balasore Best It Company|| Top 10 IT Company || Balasore Software company OdishaBalasore Best It Company|| Top 10 IT Company || Balasore Software company Odisha
Balasore Best It Company|| Top 10 IT Company || Balasore Software company Odishasmiwainfosol
 
Automate your Kamailio Test Calls - Kamailio World 2024
Automate your Kamailio Test Calls - Kamailio World 2024Automate your Kamailio Test Calls - Kamailio World 2024
Automate your Kamailio Test Calls - Kamailio World 2024Andreas Granig
 
What is Fashion PLM and Why Do You Need It
What is Fashion PLM and Why Do You Need ItWhat is Fashion PLM and Why Do You Need It
What is Fashion PLM and Why Do You Need ItWave PLM
 
英国UN学位证,北安普顿大学毕业证书1:1制作
英国UN学位证,北安普顿大学毕业证书1:1制作英国UN学位证,北安普顿大学毕业证书1:1制作
英国UN学位证,北安普顿大学毕业证书1:1制作qr0udbr0
 
Maximizing Efficiency and Profitability with OnePlan’s Professional Service A...
Maximizing Efficiency and Profitability with OnePlan’s Professional Service A...Maximizing Efficiency and Profitability with OnePlan’s Professional Service A...
Maximizing Efficiency and Profitability with OnePlan’s Professional Service A...OnePlan Solutions
 
CRM Contender Series: HubSpot vs. Salesforce
CRM Contender Series: HubSpot vs. SalesforceCRM Contender Series: HubSpot vs. Salesforce
CRM Contender Series: HubSpot vs. SalesforceBrainSell Technologies
 
Xen Safety Embedded OSS Summit April 2024 v4.pdf
Xen Safety Embedded OSS Summit April 2024 v4.pdfXen Safety Embedded OSS Summit April 2024 v4.pdf
Xen Safety Embedded OSS Summit April 2024 v4.pdfStefano Stabellini
 

Recently uploaded (20)

ODSC - Batch to Stream workshop - integration of Apache Spark, Cassandra, Pos...
ODSC - Batch to Stream workshop - integration of Apache Spark, Cassandra, Pos...ODSC - Batch to Stream workshop - integration of Apache Spark, Cassandra, Pos...
ODSC - Batch to Stream workshop - integration of Apache Spark, Cassandra, Pos...
 
Russian Call Girls in Karol Bagh Aasnvi ➡️ 8264348440 💋📞 Independent Escort S...
Russian Call Girls in Karol Bagh Aasnvi ➡️ 8264348440 💋📞 Independent Escort S...Russian Call Girls in Karol Bagh Aasnvi ➡️ 8264348440 💋📞 Independent Escort S...
Russian Call Girls in Karol Bagh Aasnvi ➡️ 8264348440 💋📞 Independent Escort S...
 
Dealing with Cultural Dispersion — Stefano Lambiase — ICSE-SEIS 2024
Dealing with Cultural Dispersion — Stefano Lambiase — ICSE-SEIS 2024Dealing with Cultural Dispersion — Stefano Lambiase — ICSE-SEIS 2024
Dealing with Cultural Dispersion — Stefano Lambiase — ICSE-SEIS 2024
 
Unveiling Design Patterns: A Visual Guide with UML Diagrams
Unveiling Design Patterns: A Visual Guide with UML DiagramsUnveiling Design Patterns: A Visual Guide with UML Diagrams
Unveiling Design Patterns: A Visual Guide with UML Diagrams
 
KnowAPIs-UnknownPerf-jaxMainz-2024 (1).pptx
KnowAPIs-UnknownPerf-jaxMainz-2024 (1).pptxKnowAPIs-UnknownPerf-jaxMainz-2024 (1).pptx
KnowAPIs-UnknownPerf-jaxMainz-2024 (1).pptx
 
SuccessFactors 1H 2024 Release - Sneak-Peek by Deloitte Germany
SuccessFactors 1H 2024 Release - Sneak-Peek by Deloitte GermanySuccessFactors 1H 2024 Release - Sneak-Peek by Deloitte Germany
SuccessFactors 1H 2024 Release - Sneak-Peek by Deloitte Germany
 
Hot Sexy call girls in Patel Nagar🔝 9953056974 🔝 escort Service
Hot Sexy call girls in Patel Nagar🔝 9953056974 🔝 escort ServiceHot Sexy call girls in Patel Nagar🔝 9953056974 🔝 escort Service
Hot Sexy call girls in Patel Nagar🔝 9953056974 🔝 escort Service
 
Open Source Summit NA 2024: Open Source Cloud Costs - OpenCost's Impact on En...
Open Source Summit NA 2024: Open Source Cloud Costs - OpenCost's Impact on En...Open Source Summit NA 2024: Open Source Cloud Costs - OpenCost's Impact on En...
Open Source Summit NA 2024: Open Source Cloud Costs - OpenCost's Impact on En...
 
Intelligent Home Wi-Fi Solutions | ThinkPalm
Intelligent Home Wi-Fi Solutions | ThinkPalmIntelligent Home Wi-Fi Solutions | ThinkPalm
Intelligent Home Wi-Fi Solutions | ThinkPalm
 
MYjobs Presentation Django-based project
MYjobs Presentation Django-based projectMYjobs Presentation Django-based project
MYjobs Presentation Django-based project
 
Building a General PDE Solving Framework with Symbolic-Numeric Scientific Mac...
Building a General PDE Solving Framework with Symbolic-Numeric Scientific Mac...Building a General PDE Solving Framework with Symbolic-Numeric Scientific Mac...
Building a General PDE Solving Framework with Symbolic-Numeric Scientific Mac...
 
Implementing Zero Trust strategy with Azure
Implementing Zero Trust strategy with AzureImplementing Zero Trust strategy with Azure
Implementing Zero Trust strategy with Azure
 
Folding Cheat Sheet #4 - fourth in a series
Folding Cheat Sheet #4 - fourth in a seriesFolding Cheat Sheet #4 - fourth in a series
Folding Cheat Sheet #4 - fourth in a series
 
Balasore Best It Company|| Top 10 IT Company || Balasore Software company Odisha
Balasore Best It Company|| Top 10 IT Company || Balasore Software company OdishaBalasore Best It Company|| Top 10 IT Company || Balasore Software company Odisha
Balasore Best It Company|| Top 10 IT Company || Balasore Software company Odisha
 
Automate your Kamailio Test Calls - Kamailio World 2024
Automate your Kamailio Test Calls - Kamailio World 2024Automate your Kamailio Test Calls - Kamailio World 2024
Automate your Kamailio Test Calls - Kamailio World 2024
 
What is Fashion PLM and Why Do You Need It
What is Fashion PLM and Why Do You Need ItWhat is Fashion PLM and Why Do You Need It
What is Fashion PLM and Why Do You Need It
 
英国UN学位证,北安普顿大学毕业证书1:1制作
英国UN学位证,北安普顿大学毕业证书1:1制作英国UN学位证,北安普顿大学毕业证书1:1制作
英国UN学位证,北安普顿大学毕业证书1:1制作
 
Maximizing Efficiency and Profitability with OnePlan’s Professional Service A...
Maximizing Efficiency and Profitability with OnePlan’s Professional Service A...Maximizing Efficiency and Profitability with OnePlan’s Professional Service A...
Maximizing Efficiency and Profitability with OnePlan’s Professional Service A...
 
CRM Contender Series: HubSpot vs. Salesforce
CRM Contender Series: HubSpot vs. SalesforceCRM Contender Series: HubSpot vs. Salesforce
CRM Contender Series: HubSpot vs. Salesforce
 
Xen Safety Embedded OSS Summit April 2024 v4.pdf
Xen Safety Embedded OSS Summit April 2024 v4.pdfXen Safety Embedded OSS Summit April 2024 v4.pdf
Xen Safety Embedded OSS Summit April 2024 v4.pdf
 

Top 20 Junit interview questions for sdet

  • 1. Top 20 JUnit Interview Questions for SDET By DevLabs Alliance Visit us at: www.devlabsalliance.com Email: training@devlabsalliance.com Contact: +91 9717514555
  • 2. JUnit Interview Questions for SDET 1. What is JUnit? JUnit is a regression testing framework which is used for performing Unit Testing of Java code. It is an open source software managed by JUnit.org community. JUnit = Java + Unit Testing
  • 3. JUnit Interview Questions for SDET 2. What are the important features of JUnit? The important features of JUnit are: • It is an open source framework. • It provides various annotations to identify the test methods. • It provides test runners for running tests. • It provides assertions to test the expected results. • It shows test progress in a bar. If test goes fine, then it shows green and when test fails, it turns to red. • It can be organized into test suites that contains test cases and other test suites as well.
  • 4. JUnit Interview Questions for SDET 3. What are the core features of JUnit? JUnit framework provides following features: • Fixtures • Test Suites • Test Runners • JUnit Classes
  • 5. JUnit Interview Questions for SDET 4. What are JUnit classes? List some of JUnit classes. JUnit classes are important classes that are used in writing and testing JUnit programs. Some of the important JUnit classes are: • Assert: Contains a set of Assert methods. • TestCase: Contains a test case that defines the fixture to run multiple tests. • TestResult: Contains a method that collects the results after execution of test case. • TestSuite: It is a composition of Junit tests.
  • 6. JUnit Interview Questions for SDET 5. What is a Fixture in JUnit? A test fixture in JUnit is defined as a fixed state of some set of objects which are used as a baseline for running tests. The main objective of a test fixture is to ensure that there is some known and fixed environment in which tests are run so that results are repeatable. It basically includes the following methods: • setUp() method which runs before every test methods. • tearDown() method which runs after every test methods.
  • 7. JUnit Interview Questions for SDET 6. What are JUnit annotations and how are they useful in JUnit? JUnit annotations are like meta-tags that can be added to our code and we can apply them to methods or in class. Annotations are very useful in JUnit as they give the information about test methods that which methods are going to run before test methods or which methods are going to run after test methods. It also gives the information that which method or class will be ignored during execution.
  • 8. JUnit Interview Questions for SDET 7. What are the important JUnit annotations? The important JUnit annotations are as follows: • @Test: The Test annotation tells that this is the test method which will run first unless specified. • @BeforeClass: The method with @BeforeClass annotation specifies that it should be run once before any of the Test method in class. • @Before: The method with @Before annotation specifies that it should be run before each test method. • @After: The method with @After annotation specifies that it should be run after the test method. • @AfterClass: This method with @AfterClass annotation specifies that it should be run after all tests have finished. This can be used for performing clean-up activities.
  • 9. JUnit Interview Questions for SDET 8. What is @ignore annotation in JUnit and how is this useful? @Ignore annotation is used to ignore that particular tests or group of tests so that build failure can be skipped. @Ignore annotation is very useful when there are cases when we can’t fix a code that is failing but still we want that method to be around so that it does not get forgotten and we can fix them later. Also it is very easy to identify all @Ignore annotation rather than finding the comment out test cases.
  • 10. JUnit Interview Questions for SDET 9. What are Parameterized tests in JUnit and what are the annotations used for this? Parameterized Tests allow developers to pass parameters into their test classes and hence allowing him to run the same test again and again using different values. Annotations used for Parameterization are: • @RunWith(Parameterized.Class) – To make a class parameterized. • @Parameters – Parameterized class must have a static method with @Parameter annotation that returns a collection of array as test data set.
  • 11. JUnit Interview Questions for SDET 10. Can we change return type of JUnit test method from void to some other type? Ideally, we should not change the return type of JUnit test from void to some other type. All the methods of JUnit tests should have a void return type. If we change the return type from void to some other type, then the test method would not be considered as a test method and would be ignored during execution of tests.
  • 12. JUnit Interview Questions for SDET 11. Name the tools with which JUnit can be easily integrated. JUnit can be easily integrated with following tools: • Eclipse • Ant • Maven
  • 13. JUnit Interview Questions for SDET 12. Name some JUnit extensions. Following are some of the JUnit extensions: • Cactus • JWebUnit • XMLUnit • MockObject
  • 14. JUnit Interview Questions for SDET 13. What are Cactus extensions and what are its common components? Cactus is a testing framework that is used for unit testing server-side java code such as Servlets, EJBs and Tag Libs. The intent of Cactus is to minimize the cost of writing tests for server-side code. It uses JUnit internally and extend it. Cactus implements an in-container strategy which means that the all the tests are executed inside the container. The components of cactus are: • Cactus framework is the core of Cactus. It provides the API to write Cactus tests. • Cactus Integration Modules are other components and they are front ends and frameworks that provide the easy way of using the Cactus framework like Ant Scripts, Eclipse plugin or Maven plugin.
  • 15. JUnit Interview Questions for SDET 14. What is JWebUnit and what are its advantages? WebUnit is a Java-based testing framework to test web applications. It wraps existing testing frameworks like Selenium and HtmlUnit with a simple, unified testing interface ans that allow us to quickly test the correctness of web applications. The various advantages of JWebUnit are as follows: • It provides a high-level Java API which is used for navigating a web-application with a set of assertions to verify the correctness of application. • This API includes form entry and submission, navigation via link, validation of table contents and other typical business web application features. • The ready to use assertions and simple navigation is helpful for more rapid test creation.
  • 16. JUnit Interview Questions for SDET 15. What is XMLUnit and what is the use of supporting classes in XMLUnit? XMLUnit is used for providing a single JUnit extension class, XMLTestCase and a set of supporting classes. Supporting classes in XMLUnit allow assertions to be made about: • Differences between 2 pieces of XML through Diff and DetailedDiff classes. • Validation of a piece of XML through Validator class. • The result of transforming a piece of XML using XSLT through transform class. • The evaluation of XPath expression on a piece of XML through XPath engine interface. • Individual nodes in a piece of XML that are exposed by Dom traversal through NodeTest class.
  • 17. JUnit Interview Questions for SDET 16. Why does JUnit only report the first failure in a single test? Reporting multiple failures in a single test implies that the test is doing too much and it is too big a unit test. So, JUnit is designed in such a way that it works best with a number of small tests. It executes each test within a separate instance of test class and reports failure on each test.
  • 18. JUnit Interview Questions for SDET 17. How can we run JUnit from command window? To run JUnit from command window, we have to follow the following steps: • Set the ClassPath: set CLASSPATH = %CLASSPATH%;%JUNIT_HOME%junit.jar • Invoke JUnit runner : java org.junit.runner.JUnitCore
  • 19. JUnit Interview Questions for SDET 18. Mention different methods of exception handling in JUnit. The different methods of Exception handling in JUnit are as follows: • Try catch statement • With @Test annotation • With catch exception library • With JUnit rule • With custom annotation
  • 20. JUnit Interview Questions for SDET 19. Mention best practices to write a unit test case in JUnit. The various best practices to be followed while writing a unit test in JUnit are as follows: • A well-written test case is the one that has a known input and expected output, which is computed before the execution of test. • A known input should always test a pre-condition and the expected output should always verify a post-condition. • It is always recommended to have atleast 2 unit test cases for each requirement, one of them is positive test and the other one is for negative test. • If any requirement have sub-requirements, then it should also have atleast 2 unit test cases as positive and negative tests.
  • 21. JUnit Interview Questions for SDET 20. Mention the differences between JUnit and TestNG. JUnit TestNG The naming convention for JUnit annotation is a bit complicated like “Before”, “After” and “Expected”. The naming convention of TestNG are easier to understand like “BeforMethod”, “AfterMethod”, etc. Grouping of test cases are not available in JUnit. Grouping of test cases is possible in TestNG. JUnit framework do not have “Dependency Test” feature. TestNG use “dependsOnMethods” to implement the dependency testing. JUnit does not support parallel execution of Selenium test cases. Parallel execution of Selenium test case is possible in TestNG. JUnit cannot re-run the failed tests. TestNG can re-run the failed tests.
  • 22. Visit us at: www.devlabsalliance.com Email: training@devlabsalliance.com Contact: +91 9717514555