The largest Interview Solution Library on the web

Interview Questions
« Previous | 0 | 1 | 2 | 3 | 4 | Next »

1.What is Testing?

Testing is the process of checking the functionality of the application whether it is working as per requirements.

2.What is Unit Testing?

Unit testing is the testing of single entity classormethod. Unit testing is very essential to every software company to give a quality product to their customers.

3.What is Manual testing?

Executing the test cases manually without any tool support is known as manual testing.

4.What is Automated testing?

Taking tool support and executing the test cases by using automation tool is known as automation testing.

5.What are the disadvantages of manual testing?

Following are the disadvantages of manual testing−

  • Time consuming and tedious − Since test cases are executed by human resources so it is very slow and tedious.
  • Huge investment in human resources − As test cases need to be executed manually so more testers are required in manual testing.
  • Less reliable − Manual testing is less reliable as tests may not be performed with precision each time because of human errors.
  • Non-programmable − No programming can be done to write sophisticated tests which fetch hidden information.

6.What are the advantages of automated testing?

Following are the advantages of automated testing−

  • Fast − Automation runs test cases significantly faster than human resources.
  • Less investment in human resources −Test cases are executed by using automation tool so less tester are required in automation testing.
  • More reliable − Automation tests perform precisely same operation each time they are run.
  • Programmable − Testers can program sophisticated tests to bring out hidden information.

7.What is JUnit?

JUnit is a Regression Testing Framework used by developers to implement unit testing in Java and accelerate programming speed and increase the quality of code.

8.What are important features of JUnit?

Following are the important features of JUnit −

  • It is an open source framework.
  • Provides Annotation to identify the test methods.
  • Provides Assertions for testing expected results.
  • Provides Test runners for running tests.
  • JUnit tests can be run automatically and they check their own results and provide immediate feedback.
  • JUnit tests can be organized into test suites containing test cases and even other test suites.
  • JUnit shows test progress in a bar that is green if test is going fine and it turns red when a test fails.

9.What is a Unit Test Case?

A Unit Test Case is a part of code which ensures that the another part of code method works as expected. To achieve those desired results quickly, test framework is required .JUnit is perfect unit test framework for java programming language.

10.What are the best practices to write a Unit Test Case?

A formal written unit test case is characterized by a known input and by an expected output, which is worked out before the test is executed. The known input should test a precondition and the expected output should test a postcondition.
There must be at least two unit test cases for each requirement: one positive test and one negative test. If a requirement has sub-requirements, each sub-requirement must have at least two test cases as positive and negative.

11.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.

12.Why not just use System.out.println for 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 class files.

13.How to install JUnit?

  • Download the latest version of JUnit, referred to below as
  • Unzip the distribution file to a directory referred to as %JUNIT_HOME%.
  • Add JUnit to the classpath−
  • Test the installation by running the sample tests distributed with JUnit
    sampletestsarelocatedintheinstallationdirectorydirectly, notthejunit. jarfile. Then simply type−
  • java org.junit.runner.JUnitCore org.junit.tests.AllTests
  • All the tests should pass with an "OK" message. If the tests don't pass, verify that junit.jar is in the CLASSPATH.

14.Why does JUnit only report the first failure in a single test?

Reporting multiple failures in a single test is generally a sign that the test does too much and it is too big a unit test. JUnit is designed to work best with a number of small tests. It executes each test within a separate instance of the test class. It reports failure on each test.

15.In Java, assert is a keyword. Won't this conflict with JUnit's assert method?

JUnit 3.7 deprecated assert and replaced it with assertTrue, which works exactly the same way. JUnit 4 is compatible with the assert keyword. If you run with the -ea JVM switch, assertions that fail will be reported by JUnit.

16.How do I test things that must be run in a J2EE container e. g. servlets, EJBs?

Refactoring J2EE components to delegate functionality to other objects that don't have to be run in
a J2EE container will improve the design and testability of the software. Cactus is an open source
JUnit extension that can be used for unit testing server-side java code.
Name the tools with which JUnit can be easily integrated.
JUnit Framework can be easily integrated with either of the followings −

  • Eclipse
  • Ant
  • Maven

17.What are the core features of JUnit?

JUnit test framework provides following important features −

  • Fixtures
  • Test suites
  • Test runners
  • JUnit classes

18.What is a fixture?

Fixture is a fixed state of a set of objects used as a baseline for running tests. The purpose of a test fixture is to ensure that there is a well known and fixed environment in which tests are run so that results are repeatable. It includes following methods −

  • setUp method which runs before every test invocation.
  • tearDown method which runs after every test method.

19.What is a test suite?

Test suite means bundle a few unit test cases and run it together. In JUnit, both @RunWith and @Suite annotation are used to run the suite test.

20.What is a test runner?

Test runner is used for executing the test cases.

« Previous | 0 | 1 | 2 | 3 | 4 | Next »

copyright © 2014 - all rights riserved by