Unit Testing

This quiz covers unit testing concept, object class testing, weather station example, state sequences, automated unit tests (setup/call/assertion), mock objects

download Export
search_insights Statistics
stylus_note White Board
Quran
calculate Calculator
dictionary Dictionary
fullscreen Full Screen

QUESTION OF
Views #: 3
Questions #: 12
Time: 10 minutes
Pass Score: 80.0%
Style
Mode

Three Stages of Development Testing

1 pts

Development testing includes three stages. Match each stage to its correct focus.

To complete the line match

  1. Click on an item in the first group
  2. Click on the match in the second group

To delete a match, double click on a line

Stage

Unit testing
System testing
Component testing

Focus

Testing the functionality of objects or methods individually
Testing component interactions in a partial or complete system
Testing component interfaces that provide access to component functions
note_alt Add notes
flag Flag

Correct Answer

Explanation

Unit Testing Scope

1 pts
volume_mute

What is the primary subject of unit testing?

note_alt Add notes
flag Flag

Correct Answer

Explanation

Testing Object Classes Comprehensively

1 pts
volume_mute

When testing object classes, which of the following should be covered to achieve comprehensive testing? Select all that apply.

note_alt Add notes
flag Flag

Correct Answer

Explanation

Weather Station Object - Unit Testing

1 pts
volume_mute

Consider a WeatherStation object with a single constant attribute (identifier) and methods including reportWeather(), reportStatus(), powerSave(), remoteControl(), reconfigure(), restart(), and shutdown().

WeatherStation identifier reportWeather() reportStatus() powerSave(instruments) restart(instruments) shutdown(instruments)

Why must the restart() method be executed before testing the shutdown() method?

note_alt Add notes
flag Flag

Correct Answer

Explanation

Inheritance and Object Class Testing

1 pts
volume_mute

Why does inheritance or generalization make object class testing more complicated?

note_alt Add notes
flag Flag

Correct Answer

Explanation

State Sequence Testing for Weather Station

1 pts
volume_mute

Using a state model, testers identify sequences of state transitions to test. Which of the following are valid state transition sequences for the weather station that should be tested? Select all that apply.

note_alt Add notes
flag Flag

Correct Answer

Explanation

Three Parts of an Automated Test

1 pts
Please drag and drop the options to sort them

An automated unit test has three standard parts. Arrange them in the correct order.

Call part - call the object or method to be tested
Setup part - initialize the system with the test case inputs and expected outputs
Assertion part - compare the result of the call with the expected result
note_alt Add notes
flag Flag

Correct Answer

Explanation

Automated Test Assertion Outcome

1 pts
volume_mute

In an automated unit test, what happens when the assertion evaluates to false?

note_alt Add notes
flag Flag

Correct Answer

Explanation

Purpose of Mock Objects

1 pts
volume_mute

What is the primary purpose of using mock objects in unit testing?

note_alt Add notes
flag Flag

Correct Answer

Explanation

Mock Object Example - Database

1 pts
volume_mute

A development team is unit testing a class that calls a database to retrieve customer records. The database setup takes 30 seconds each test run. They decide to use a mock object. What would the mock object database typically contain?

note_alt Add notes
flag Flag

Correct Answer

Explanation

Mock Objects for Rare Events

1 pts
volume_mute

Beyond replacing slow dependencies, mock objects can also be used for another purpose in unit testing. What is this additional use?

note_alt Add notes
flag Flag

Correct Answer

Explanation

Unit Testing and Debugging Relationship

1 pts

Complete the statement about the relationship between development testing and debugging: "Development testing is primarily a (1) process and is usually interleaved with (2) - the process of locating problems with the code and changing the program to fix these problems."

Please drag and drop the selected option in the right place or type it instead
validation testing
defect testing
debugging
code review
note_alt Add notes
flag Flag

Correct Answer

Explanation