JUnit Question:

Download Job Interview Questions and Answers PDF

What Is a JUnit Test Fixture?

JUnit Interview Question
JUnit Interview Question

Answer:

A test 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. Examples of fixtures:

* Loading a database with a specific, known set of data
* Copying a specific known set of files
* Preparation of input data and setup/creation of fake or mock objects

In other word, creating a test fixture is to create a set of objects initialized to certain states.

If a group of tests requires diferent test fixtures, you can write code inside the test method to create its own test fixture.

If a group of tests shares the same fixtures, you should write a separate setup code to create the common test fixture.

Download JUnit Interview Questions And Answers PDF

Previous QuestionNext Question
How Many Test Runners Are Supported in JUnit 3.8?Can You Explain the Life Cycle of a JUnit 3.8 Test Case Class?