Multiple choice technology testing

To test a function, the programmer has to write a _________, which calls the function to be tested and passes it test data.

  1. Stub

  2. Driver

  3. Proxy

  4. None of the above

Reveal answer Fill a bubble to check yourself
B Correct answer
Explanation

To solve this question, the user needs to know about software testing techniques, specifically unit testing. The user must identify the correct term for a program that calls a function with test data to test its functionality.

Now, let's go through each option and explain why it is right or wrong:

A. Stub: A stub is a piece of code that simulates the behavior of a function or module. It is used in place of the actual function or module during testing. While a stub can be used in testing, it is not the correct term for a program that calls a function with test data to test its functionality.

B. Driver: A driver is a program that calls a function with test data to test its functionality. It is used to test functions that rely on input from other functions or modules. This option is correct.

C. Proxy: A proxy is an intermediary between two systems that allows them to communicate with each other. It is not the correct term for a program that calls a function with test data to test its functionality.

D. None of the above: This option is incorrect because option B, Driver, is the correct answer.

The Answer is: B

AI explanation

The correct answer is Driver. In unit testing, when a function/module you want to test needs to be invoked, but the calling code (e.g., main program) doesn't exist yet, you write a test driver — a piece of code that calls the function under test and supplies it with test data, then checks the returned results. A Stub is the opposite: a dummy replacement for a called (lower-level) module that the function under test depends on, not something that calls it. A Proxy is a design-pattern object that stands in for another object to control access to it, unrelated to test harnesses. 'None of the above' is wrong since Driver is a valid, standard testing term.