CS 362

अब Quizwiz के साथ अपने होमवर्क और परीक्षाओं को एस करें!

Each unittest test case must include at least one ________. Description Setup() call Assertion Test

Assertion

Context: Random Testing What is the input domain for the following? The following my_abs function takes a value and returns the absolute value of the passed in val. def my_abs(val): if(val > 0): return val else return -val Real numbers Integers Imaginary numbers Rational numbers

Real numbers

Which of the following are examples of Functional Testing? Usability Testing Performance Testing Regression Testing Unit Testing

Regression Testing, Unit Testing

Which of the following are examples of Non-functional Testing? Scalability Testing Unit Testing Integration Testing Performance Testing

Scalability Testing, Performance Testing

Context: Testing Environments Why not just put all the set up steps within each step? It is because we want to keep our code __ ? (3 letters)

dry

Context: Mocks ___ simulate the behavior of a service and its actions can be verified.

mocks

Context: Black Box Testing Given the following requirements, which would Boundary Testing suggest as good test cases? Valid Password -At least 8 characters -No more than 20 characters -At least 1 special character -At least 1 digit password of length 8 password with 0 special characters password of length 16 password with 4 digits

password of length 8 password with 0 special characters

Context: Code Review To whom does the following piece of advice apply? "If you identify aterm-31 road block, provide a detour" Code Reviewee Code Reviewer

Code Reviewer

What happens during the Requirements phase? Craft user stories and use cases Identifying the software languages to use Interviews with stakeholders Produce a design document

Craft user stories and use cases, Interviews with stakeholders

A Fault is a mistake True False

False

An Error is a deviation from the expected behavior True False

False

Context: Testing Environments The @classmethod used with setUpClass() and tearDownClass() is called a modifier. True False

False

What happens during the Design phase? Layout the architecture of the program Start coding Determine acceptable software performance Produce a design document

Layout the architecture of the program, Produce a design document

Which of the following are reasons testing is important? Life and Death Happier customers Saves money Saves time

Life and Death Happier customers Saves money Saves time

Given the following scenario, identify if it would best be tested manually or with an automated system. You are a game developer and received an angry email from a customer saying they fell through the ground when trying to climb a particular hill. Automated Manual

Manual

Context: Beyond Unit Testing The purpose of Acceptance Testing is for ______ to "sign off" on if the software meets their expectations. Supervisors Code Reviewers Stakeholders Co-workers

Stakeholders

Identify the 4 elements to a testing framework. Test runner Test coverage Test case Test fixture Test suite

Test runner, Test case, Test fixture, Test suite

The Therac-25 machine was used for radiation therapy in the 1980's. It had two modes of radiation: low and high. During the accidents, the machine would incorrectly display the machine was set to low power when in fact it was configured for high power. What caused this deadly situation? A brief power surge during the realignment phase Poor user interface The technician input commands very quickly Failure to update the software with an urgent patch

The technician input commands very quickly

A Failure occurs because of a "bug" in the code: a fault True False

True

Context: Continuous Integration When using Continuous Integration, every commit to master should be built and tested True False

True

Context: Mocks If we want to override the behavior of an imported item, we need to use patch True False

True

Context: White Box Testing Branch Coverage subsumes Statement Coverage. True False

True

Unit Testing is when the smallest component of a software system is verified to produce the expected behavior. True False

True

You can create a test class by right clicking on the name of the function/class. True False

True

What is the testing framework we use in this course? JUnit Nose Pytest Unittest

Unittest

Context: Mocks Given the following code snippet, what is the output of the print statement? mock = Mock() mock.func("Hello World") mock.func("Greetings Planet") print(mock.func.call_args) [call('Hello World')] [call('Hello World'), call('Greetings Planet')] [call('Greetings Planet')] undefined

[call('Greetings Planet')]

Context: TDD Answer this question given the following specification: fizz_buzz takes an integer and returns a string based on the following rules: -a number divisible by 3 returns fizz -a number divisible by 5 returns buzz -a number divisible by 3 and 5 returns fizzbuzz -all other numbers return the number as a string (e.g. 1 returns '1') Imagine you are following Test Driven Development and have written your first test for fizz_buzz: def test1(self): input = 1 expected = '1' self.assertEqual(fizz_buzz(input), expected) Using what you know about the steps of TDD fill in the missing line below: def fizz_buzz(num): __________

return '1'

Context: Mocks Given the following code snippet, what goes in the blank? from unittest.mock import Mock mock = Mock() # Set return_value mock.abs.______ = "7" return return_value returnValue value

return_value

Context: Testing Environments Which of the following is called before each test case in a TestCase object? setUp() setUpClass() tearDown() tearDownClass()

setUp()

Context: Mocks Given the following snippet. If we wanted to use a mock to trigger an exception, what would we use in the blank? # Mock file reader to control its behavior open = Mock() def load_file(): # Does absolutely nothing other than raise the desired exception content = open('temp_file.txt') if content.length != 0: return content return None class TestCase(unittest.TestCase): def test_read_file(self): # Test for IOError open.______ = IOError # This is a context manager that allows us to test for exceptions with self.assertRaises(IOError): load_file() side_effect exception throw raise

side_effect

Context: Mocks ____ contain predefined data that is returned when called, but do not imitate behavior.

stubs

Context: Testing Environments Which of the following is called after all the test cases in a TestCase Object are run (not after each test)? setUp() setUpClass() tearDown() tearDownClass()

tearDownClass()


संबंधित स्टडी सेट्स

Chapter 4 - Introduction to SQL Syntax & Queries

View Set

PrepU - Ch. 54 - Mgmt of Patients with Kidney Disorders (no explanation/choices for these)

View Set

PSY321 Lecture 4 Chapter 6- Self and Personality

View Set

Chapter 15: The Special Senses (A)

View Set

Unit 15: Real Estate Taxes and Other Liens

View Set