FX Flashcards

1
Q

What is software verification?

A

ensure that the actual implementation meets the requirements set forth at the beginning

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
2
Q

The main thrust of Software Engineering II is on Testing. If you had to hazard a guess, which of the five phases above do you think Testing falls into?

A

If you answered Verification you would be correct. But if you think Verification is something that happens after all the other phases are complete, you would be incorrect. Other than the Requirements phase, testing can play a crucial role throughout the software development process.

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
3
Q

What is unit testing?

A

Unit Testing is when individual units of the software are tested…

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
4
Q

What is a failure?

A

Failure - a deviation from the expected behavior

These failures occur because there exists a “bug” in the code (a fault).

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
5
Q

What is the a fault

A

Fault: - an instance of incorrect code that can lead to a failure

A fault is introduced to the program when a programmer makes a mistake (an error).

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
6
Q

What is a error?

A

Error - a mistake that introduces a fault (e.g. typo and conceptual misunderstanding)

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
7
Q

Functional Testing

A

These types of tests are used to verify that the software meets the requirement specifications when it comes to functionality; does the software do the things it is expected to do?
Examples:

Does clicking “save” actually save the changes to the hard drive?
Does the search algorithm actually find the shortest path?
Does the isItPrime function correctly identify prime numbers?
Does the database correctly supply responses to the client?

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
8
Q

Non-functional Testing

A

These types of tests are used to verify that the software performs at the required levels. This can literally mean performance, but also usability, reliability, and robustness.
Examples

Does the webpage load in less than 2 seconds?
Does the interface provide enough clues for easy navigation?
Does the system successfully recover from a catastrophic failure?
Does the service support 10,000+ active users at a time?

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
9
Q

You are interested in learning how user friendly your software is.

A

Manual - This type of task really requires a human to interact with the software.

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
10
Q

Scenarios 2: You want to make sure your new changes didn’t break your existing features

Automated or Manual

A

Automated - Using pre-written tests that were known to pass, you can quickly verify that your changes didn’t cause any of them to fail. This is called Regression Testing.

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
11
Q

Scenarios 3: You want to test for game breaking bugs in a massively online multiplayer game.

A

Manual While automated tests could be used to test components of the game, testing the combined product really requires humans actively trying to break the game while it is running.

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
12
Q

Scenarios 4: You want to verify your system can handle a large range of possible inputs.

A

Automated - Instead of having a human try to input thousands of possible inputs, automated tests can randomly generate inputs in a fraction of the time. This is called Random Testing.

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
13
Q

When is black box testing useful?

A

Black Box Testing is when you write tests based purely on the description provided for the software (a.k.a. the specification).

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
14
Q

What are the limitations of black box testing?

A

It isn’t possible to test every possible input, so tests may miss logic branches/program paths untested (more on this in the White Box module)
There is no way to know why the failure occurs, just that the failure indicates a fault
Poorly written specifications can lead to inaccurate tests

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
15
Q

Random Testing - Advantages

A

Advantages
Quick to write
Can cover large portions of the input domain with very little code
Tests have no bias
Can potentially generate an input that no one considered

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
16
Q

Random Testing Disadvantages

A

Many random inputs could fall under the same “test case”, so become redundant and a waste of resources
May not test the tricky parts of the input domain like edge cases
Without any targeting, random inputs could easily miss glaring errors
Randomly selecting inputs for each test run could see some runs pass while others fail

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
17
Q

How does Partition Testing improve a testing suite?

A

partition Method is a way of reducing the potentially thousands of different combinations of testable features (i.e. test cases) down to a number that can be realistically implemented.

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
18
Q

When is white box testing useful?

A

White box testing focuses on verifying that all the code works as intended by trying to have as much of it run as possible during testing. This is done through something called coverage.

Definition Time

Code coverage is the extent to which a given test suite executes the source code of the software.

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
19
Q

Why is 100% statement coverage not enough?

A

All the non-executed statements are inside conditionals that aren’t triggered:

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
20
Q

Do you think 100% branch coverage means 100% statement coverage? Why?

A

100% branch coverage guarantees 100% statement coverage. In this way we can say branch coverage subsumes statement coverage.

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
21
Q

What is the input domain for my_abs?

def my_abs(val):
    if(val > 0):
        return val
    else
        return -val
A

Answer-The input domain consists of all real numbers!

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
22
Q

What is an oracle?

A

The oracle’s sole job is to watch for error states in the software and save the random inputs that generated those states for later inspection. . An oracle can be as simple as displaying error generating input to the screen or it could be an elaborate piece of software that generates formal bug reports.

23
Q

How can we make our random testers “smarter”?

A

With guided random testing, we use what is called a heuristic to help us make our random generation smarter

24
Q

How does random testing help with large input domains?

A

Can cover large portions of the input domain with very little code

25
Q

value in dynamically adding tests to a testing suite

A

rror recovery, an accurate number of tests run, and the ability to use asserts with random tests

26
Q

What software design approach is most directly associated with TDD?

A

Agile

27
Q

What does it mean to write the “bare minimum” of code?

A

Write the bare minimum of code to make the test pass

28
Q

When do we know we are done?

A

stop development after adding “enough” tests without triggering a new failure

29
Q

can you identify where in the process we refactored?

A

We refactored everytime we added test cases that broke our implementation. So when we changed return ‘1’ to return str(num), that was refactoring. We did this repeatedly as we went along and fixed our failing tests.

30
Q

Define Continuous Integration

A

The primary goal of CI is to have many developers working on the same codebase at the same time. CI as a set of guiding principles

31
Q

Continuous Integration Principles

A

Use a VCS like Git to maintain a central codebase.
Building the software should be automated and easily triggered. Once built, the software should be able to test itself against a provided test suite. Everyone needs to commit work to the shared codebase at least once a day. Every commit to master should be built and tested. Mandatory Code Review when requesting changes to be merged into the shared codebase

32
Q

What is a Fagan Inspection?

A

A process of trying to find defects in documents (such as source code or formal specifications) during various phases of the software development process

Planning - gathering participants and resources needed for the inspection process

Overview - meeting to discuss the important aspects of the project

Preparation - participants must review the material before the meeting

Inspection meeting - the actual moment the code is physically inspected for defects

Rework - any defects that are discovered are “fixed”

Follow-up - someone follows up with the developer to ensure the reworks have been done correctly

33
Q

How can I be a good Code Reviewer?

A

Read every line you are assigned
Put effort into your feedback
Think about how you would do it

34
Q

How can I be a good Code Reviewee?

A

Proofread
Make it worth it
Shine a light on it

35
Q

What is the difference between a Stub and a Mock?

A

Stubs

Stubs contain predefined data that is returned when called, but do not imitate behavior.

Mocks

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

36
Q

What does Unittest’s patch do?

A

which looks up an object in a given module and replaces that object with a Mock . Usually, you use patch() as a decorator or a context manager to provide a scope in which you will mock the target object.

37
Q

When is it appropriate to employ MC/DC?

A

Modified Condition/Decision Coverage’s purpose is to only test the important conditions to limit the number of test cases required.

38
Q

Which type of testing requires the input of the client/user?

A

Acceptance Testing

39
Q

Which type of testing requires the input of the client/user?

A

Acceptance Testing

40
Q

What are the differences between a Mutation-Based and Generation-Based Fuzzer?

A

Mutation-Based - This type of fuzzer starts by selecting a valid input. It then mutates the input in some random way and throws it at the software under test. The tester can achieve decent coverage by curating a varied list of valid inputs that would trigger different states in the software.

41
Q

Generation-Based -

A

As you may have guessed, generation fuzzers do not start with valid inputs. These fuzzers use some “knowledge” of the input domain to create the random inputs. This is similar to how we used “rules” to generate random inputs to test a password validator. The difference here is that in Exploration: Random Testing we were unit testing and now we are more concerned about how these random inputs affect the system.

42
Q

What are the differences between Load and Stress Testing?

A

Load Testing is where software is tested for performance under expected operating conditions.
Stress Testing is where software is tested to ensure it functions under extreme operating conditions.

43
Q

Fuzzing

A

aims to discover errors in programs by feeding them random inputs

44
Q

Fuzzer

A

is the tool/software used to perform Fuzzing

45
Q

What happens during the Requirements phase?

A

Interviews with stakeholders

Craft user stories and use cases

46
Q

What happens during the Design phase?

A

Layout the architecture of the program

Produce a design document

47
Q

Which of the following are examples of Functional Testing?

A

Regression Testing

Unit Testing

48
Q

Identify the 4 elements to a testing framework.

A

Test runner
Test case
Test fixture
Test suite

49
Q

Each unittest test case must include at least one ________.

A

Assertion

50
Q

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"
A

return_value

51
Q

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)

A

call(‘Greetings Planet’)

52
Q

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()
A

side_effect

53
Q

Which of the following is called before each test case in a TestCase object?

A

setUp()

54
Q

Which of the following is called after all the test cases in a TestCase Object are run (not after each test)?

A

tearDownClass()