junit interview question set 2/jUnit Interview Questions and Answers for Freshers & Experienced

If the JUnit method’s return type is ‘string’, what will happen?

JUnit test methods are designed to return ‘void’. So the execution will fail.

Posted Date:- 2021-08-30 01:23:45

What is the difference between manual testing and automated testing?

Manual testing is performed by humans, so it is time-consuming and costly. Automated testing is performed by testing tools or programs, so it is fast and less costly.

Posted Date:- 2021-08-30 01:23:01

Give a brief account of the Test Suite with respect JUnit

Test Suite usually refers to the principle of compiling a variety of unit test cases to run it concurrently. In this context, it is interesting to note that in JUnit, both Run With and Suite comments are being used to avail maximum benefits.

Posted Date:- 2021-08-30 01:22:07

Explain how you will log in into any site if it is showing any authentication popup for username and password?

If there is a pop up for logging in, we need to use the explicit command and verify if the alert is actually present. The below code helps you understand the use of explicit wait commands.

1. WebDriverWait wait = new WebDriverWait(driver, 10);
2. Alert alert = wait.until(ExpectedConditions.alertIsPresent());
3. alert.authenticateUsing(newUserAndPassword(**username**, **password**));

Posted Date:- 2021-08-30 01:21:21

Which technique should be considered in the script “if there is neither frame id nor frame name”?

If frame name and frame id is not available, then we can use frame by index. For example, there are 3 frames in a web page and if none of them have a frame name and frame id, then we can still select those frames by using frame (zero-based) index attribute. All the frames will have an index number like the first frame would be at index “0”, the second at index “1” and the third at index “2”.

Posted Date:- 2021-08-30 01:20:22

What is meant by Defect Cascading?

efect cascading is a defect which is caused by another defect. One defect triggers the other defect. When a defect is present in any stage but is not identified, hide to other phases without getting noticed. This will result in an increase in the number of defects.

Let us understand this by an example.

You are designing the Login Module of a WebPage:

>> In phase 1 – You are designing a Register User Module for Login and mobile number is mandatory but you can leave it blank due to a bug that gets unnoticed.
>> In Phase 2 – You will design the login form having username and password. The password is OTP which will be sent to User’s registered mobile number.
Now as the Register module has a bug that mobile numbers can be left blank so this may lead to Login failure or maybe some system error or crash if a null mobile number is not handled. This is known as defect cascading.

Posted Date:- 2021-08-30 01:18:22

How is the testing of the ‘protected’ method done?

To test the protected method, the test class is declared in the same package as the target class.

Posted Date:- 2021-08-30 01:17:03

What is Object Repository? How can we create an Object Repository in Selenium?

Object Repository refers to the collection of web elements belonging to Application Under Test (AUT) along with their locator values. With respect to Selenium, objects can be stored in an excel sheet which can be populated inside the script whenever required.

Posted Date:- 2021-08-30 01:16:13

What is TestNG?

It is an advanced framework which is designed in a way to leverage the benefits by both the developers and testers. It also has an inbuilt exception handling mechanism which lets the program to run without terminating unexpectedly.

Posted Date:- 2021-08-30 01:15:29

Explain Load Testing on websites?

To access a website, a user sends a “request” to that website’s server, and the server sends back a response in the form of the website you want to access. To load test a website, quality assurance engineers and automation engineers just need to multiply the number of responses sent to simulate different traffic loads. The web server’s response to the influx of virtual users can then be measured. This is used to determine performance issues and server capacity.

Posted Date:- 2021-08-30 01:14:45

Is Automation testing in agile methodology useful?

Automation testing is very useful in agile methodology and helps in achieving maximum test coverage in a lesser time of the sprint.

Posted Date:- 2021-08-30 01:14:06

Which test cases are written first: white boxes or black boxes?

Usually, black box test cases are written first and white box test cases later. To write black box test cases we need the requirement document and design or project plan. These documents are easily available at the initial start of the project. White box test cases cannot be started in the initial phase of the project because they need more architectural clarity which is not available at the start of the project. So normally white box test cases are written after black box test cases are written.

Posted Date:- 2021-08-30 01:13:18

Name some code smells which makes it hard to achieve high code coverage?

Long method, Large conditionals

Posted Date:- 2021-08-30 01:12:14

Mention different methods of exception handling in JUnit?

There are different methods of exception handling in JUnit

<> Try catch idiom
<> With JUnit rule
<> With @Test annotation
<> With catch exception library
<> With customs annotation

Posted Date:- 2021-08-30 01:11:36

What do you mean by boundary value analysis?

Boundary Value Analysis (BVA) is a black box test design technique which is applied to see if there are any bugs at the boundary of the input domain.

Posted Date:- 2021-08-30 01:10:31

What do you mean by regression and confirmation testing?

1. Regression Testing: It is defined as a type of software testing to confirm that a recent code change has not adversely affected existing features.
2. Confirmation Testing: When a test fails because of the defect, the defect is reported. Then a new version of the software is submitted whose defect is fixed. This is called confirmation testing or re-testing.

Posted Date:- 2021-08-30 01:09:06

Define installation with respect to JUnitD

A fixture is also known as a constant state of a collection of objects that can be used for the execution of tests. The main aim of using a test fixture lies in the fact that there should be a familiar and fixed environment. Moreover, these tests are run so that the results are repeatable. It comprises the following procedures.

<> The setup method which runs every test
<> The teardown procedure which runs after the execution of a particular test

Posted Date:- 2021-08-30 01:07:37

What are the Cactus extensions? And what are its common components?

Cactus is a simple test framework. It is for unit testing server-side java code such as servlets, EJBs and Tag Libs. The idea of Cactus is to minimize the cost of writing tests on server-side code. It uses Junit internally and extends the same. The way cactus implements it is through an in-container strategy.

Cactus Ecosystem is made of many components
Cactus Framework is the core of Cactus. To write Cactus tests, it has an API.
Cactus Integration Modules is another component which are front ends and frameworks that provide quicker ways of using the Cactus Framework be it Ant scripts or Eclipse plugin or Maven plugin.

Posted Date:- 2021-08-30 01:04:46

Should testing be done only after the build and execution phases are complete?

Testing is always done after the build and execution phases Earlier we catch a defect, the more cost effective it is. For example, fixing a defect in maintenance is ten times more costly than fixing it during execution.

Posted Date:- 2021-08-30 01:03:59

When should I use Selenium Grid?

Selenium Grid can be used to execute same or different test scripts on multiple platforms and browsers concurrently so as to achieve distributed test execution, testing under different environments and saving execution time remarkably.

Posted Date:- 2021-08-30 01:03:18

What is the difference between Absolute and Relative Path?

Absolute XPath

It is the direct way to find the element, but the disadvantage of the absolute XPath is that, if there are any changes made in the path of the element then that XPath gets failed. For example: /html/body/div[1]/section/div[1]/div

Relative XPath

For Relative XPath, the path starts from the middle of the HTML DOM structure. It begins with the double forward slash (//), which means it can search the element anywhere at the webpage. For example: //input[@id=‘ap_email’]

Posted Date:- 2021-08-30 01:02:44

What are the various components of Selenium?

Different components of Selenium are:

Selenium Integrated Development Environment (IDE)
Selenium Remote Control (RC)

Posted Date:- 2021-08-30 01:02:02

What are the benefits of Automation testing?

Benefits of Automation testing are:

>> Supports execution of repeated test cases
>> Aids in testing a large test matrix
>> Enables parallel execution
>> Encourages unattended execution
>> Improves accuracy thereby reducing human-generated errors
>> Saves time and money

Posted Date:- 2021-08-30 01:01:35

What is coverage and what are the different types of coverage techniques?

The parameter used in software testing to describe the extent to which the source code is tested is known as coverage. There are three basic types of coverage techniques and they are:

>> Statement coverage: It ensures that each line of source code has been executed and tested.
>> Decision coverage: It assures that every decision (true/false) in the source code has been executed and tested.
>> Path coverage: Here we ensure that every possible route through a given part of the code is executed and tested.

Posted Date:- 2021-08-30 00:59:47

On what basis the acceptance plan is prepared?

Basically, the acceptance document is prepared using the following inputs.

>> Requirement document: It specifies what exactly is needed in the project from the customers perspective.
>> Input from the customer: This can be discussions, informal talks, emails, etc.
>> Project plan: The project plan prepared by the project manager also serves as good input to finalize your acceptance test.

Posted Date:- 2021-08-30 00:58:57

What is usability testing?

It is a testing methodology where the end customer is asked to use the software to see if the product is easy to use, to see the customer’s perception and task time. An accurate way to finalize the customer point of view for usability is by using prototype or mock-up software during the initial stages.

Posted Date:- 2021-08-30 00:57:55

What is Verification and Validation in Software Testing?

Verification: It is a static analysis technique. Here, testing is done without executing the code. Examples include – Reviews, Inspection, and walkthrough.

Validation: It is a dynamic analysis technique where testing is done by executing the code. Examples include functional and non-functional testing techniques.

In the V model, the development and QA activities are done simultaneously. There is no discrete phase called Testing, rather testing starts right from the requirement phase. The verification and validation activities go hand in hand.

Posted Date:- 2021-08-30 00:57:09

List out some advantages of automated testing.

Some of the advantages of automated testing are:

>> It is very fast.
>> Investment is very less.
>> Testing is more reliable.
>> The testing can be programmed.

Posted Date:- 2021-08-30 00:56:29

Do you need to write a test class for every class that needs to be tested?

No. We need not write an independent test class for every class that needs to be tested. If there is a small group of tests
sharing a common test fixture, you may move those tests to a new test class. If you have two groups of tests that you think you'd like
to execute separately from one another, it is wise to place them in separate test classes.

Posted Date:- 2021-08-30 00:54:19

For which conditions, the methods Get () and Set () can be left out for testing?

You should do this test to check if a property has already been set (in the constructor) at the point you wish to call getX().
In this case you must test the constructor, and not the getX() method. This kind of test is especially useful if you have multiple
constructors.

Posted Date:- 2021-08-30 00:53:49

: Why not just use system.out.println () for Unit Testing?

Debugging the code using system.out.println() will lead to manual scanning of the whole output every time the program is
run to ensure the code is doing the expected operations. Moreover, in the long run, it takes lesser time to code Junit methods and test
them on our files.

Posted Date:- 2021-08-30 00:53:18

What Is Junit TestCase?

JUnit TestCase is the base class, junit.framework.TestCase, that allows you to create a test case. (Although, TestCase class
is no longer supported in JUnit 4.4.)
A test case defines the fixture to run multiple tests. To define a test case
-Implement a subclass of TestCase
-Define instance variables that store the state of the fixture
-Initialize the fixture state by overriding setUp
-Clean-up after a test by overriding tearDown

Posted Date:- 2021-08-30 00:51:44

How to write a simple Junit test class?

To write a test case, follow these steps:
Define a subclass of TestCase.
Override the setUp() method to initialize object(s) under test.
Optionally override the tearDown() method to release object(s) under test.
Define one or more public testXYZ() methods that exercise the object(s) under test and assert expected results.

Posted Date:- 2021-08-30 00:51:14

When are Unit Tests written in Development Cycle?

Tests are written before the code during development in order to help coders write the best code. Test-driven development
is the ideal way to create a bug free code. When all tests pass, you know you are done! Whenever a test fails or a bug is reported, we
must first write the necessary unit test(s) to expose the bug(s), and then fix them. This makes it almost impossible for that particular
bug to resurface later.

Posted Date:- 2021-08-30 00:50:50

Why do you use Junit to test your code?

Junit provides a framework to achieve all the following-:
Test early and often automated testing.
Junit tests can be integrated with the build so regression testing can be done at unit level.
Test Code reusage.
Also when there is a transfer Junit tests act as a document for the unit tests.

Posted Date:- 2021-08-30 00:50:14

Who should use Junit, developers or testers?

Used by developers to implement unit tests in Java. Junit is designed for unit testing, which is really a coding process, not a
testing process. But many testers or QA engineers are also required to use Junit for unit testing.

Posted Date:- 2021-08-30 00:49:51

What are the Cactus extensions? And what are its common components?

Cactus is a simple test framework. It is for unit testing server-side java code such as servlets, EJBs and Tag Libs. The idea of Cactus is to minimize the cost of writing tests on server-side code. It uses Junit internally and extends the same. The way cactus implements are through an in-container strategy.

Cactus Ecosystem is made of many components −

1. Cactus Framework is the core of Cactus. To write Cactus tests, it has an API.
2. Cactus Integration Modules is another component which are front ends and frameworks that provide quicker ways of using the Cactus Framework be it Ant scripts or Eclipse plugin or Maven plugin.

Posted Date:- 2021-08-30 00:48:58

What are top 2-3 advantages of mocking?

1. Verify interactions 2. Test the block of code in isolation

Posted Date:- 2021-08-30 00:48:11

What are top 2-3 characteristics of Hard-to-test code?

Long methods, Long conditionals, mixing concerns, bulky constructors

Posted Date:- 2021-08-30 00:47:04

Can we change return type of JUnit test method from void to some other type?

Ideally you should not do this. All the JUnit test methods should have a void return type. If you change the return type then
the test method would not be considered as a test method and would be ignored during execution of tests.

Posted Date:- 2021-08-30 00:46:15

Name some Junit extensions?

Following are some of the JUnit extensions −

Cactus
JWebUnit
XMLUnit
MockObject

Posted Date:- 2021-08-30 00:45:20

What is XMLUnit? What is the use of supporting classes in XMLUnit?

XMLUnit is used as a single JUnit extension class, XMLTestCase, and a set of supporting classes. Supporting classes assertions are made about following−

The distinction between two pieces of XML such as through Diff and DetailedDiff classes.
The validation of a piece of XML through the Validator class.
The result of transforming a piece of XML using XSLT through Transform class.
The evaluation of an XPath expression from an XML through classes that implement the XPath engine interface.
Individual nodes in a piece of XML which are exposed by DOM Traversal through Node Test class.

Posted Date:- 2021-08-30 00:44:04

Difference between Assert and Verify ?

Assert works only if assertions ( -ea ) are enabled which is not required for Verify. Assert throws an exception and hence doesn’t continue with the test if assert evaluates to false whereas it’s not so with Verify.

Posted Date:- 2021-08-30 00:37:14

Name the tools with which JUnit can be easily integrated.

JUnit Framework can be easily integrated with either of the followings − Eclipse
Ant
Maven.

Posted Date:- 2021-08-30 00:36:46

What happens if a test method throws an exception?

The JUnit runner will declare that test as fail when the test method throws an exception.

Posted Date:- 2021-08-30 00:36:15

How do I test a private method?

The private methods cannot be tested as any private method only be accessed within the same class. The private method need to tested manually or be converted to protected method.

Posted Date:- 2021-08-30 00:35:46

How do I execute JUnit from command line?

Executng Junit from command line involves 2 steps. set the ClassPath to include JUnit core libraries. set CLASSPATH=%CLASSPATH%;%JUNIT_HOME%junit.jar
2.Invoke JunitCore. java org.junit.runner.JUnitCore

Posted Date:- 2021-08-30 00:32:41

What are the different methods of exception handling in JUnit?

There are different ways of exception handling in JUnit. Try catch idiom.
Using JUnit rule.
@Test annotation.
Using catch exception library.
Using customs annotation.

Posted Date:- 2021-08-30 00:32:13

In SDLC, When is the right time to start writing unit tests?

Test-along if not test-driven; Writing unit tests towards end is not very effective. Test-along technique recommends developers to write the unit tests as they go with their development.

Posted Date:- 2021-08-30 00:31:01

What are the top advantages of writing unit tests?

The advantages of writing unit tests include Design testability, Code testability and Code maintainability as good unit tests enforces Object Oriented principles such as Single Responsibility etc. which enables people to avoid code smells such as long classes, long methods, large conditionals etc.

Posted Date:- 2021-08-30 00:28:02

Search
R4R Team
R4R provides jUnit Freshers questions and answers (jUnit Interview Questions and Answers) .The questions on R4R.in website is done by expert team! Mock Tests and Practice Papers for prepare yourself.. Mock Tests, Practice Papers,junit interview question set 2,jUnit Freshers & Experienced Interview Questions and Answers,jUnit Objetive choice questions and answers,jUnit Multiple choice questions and answers,jUnit objective, jUnit questions , jUnit answers,jUnit MCQs questions and answers R4r provides Python,General knowledge(GK),Computer,PHP,SQL,Java,JSP,Android,CSS,Hibernate,Servlets,Spring etc Interview tips for Freshers and Experienced for jUnit fresher interview questions ,jUnit Experienced interview questions,jUnit fresher interview questions and answers ,jUnit Experienced interview questions and answers,tricky jUnit queries for interview pdf,complex jUnit for practice with answers,jUnit for practice with answers You can search job and get offer latters by studing r4r.in .learn in easy ways .