OOP - Testing Objects Flashcards

1
Q

Unit Test

A

Scripts designed to test the performance of a single function.
How to Use in a Sentence: “As the program scales, unit tests, will ensure classes will continue to behave as expected.”

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

Arrange

A

Top section of a test designed to include things to arrange or set up like creating variables or instances. Used in a sentence: “How do I want this test to act? What function will trigger the test and provide inputs?”

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

Act

A

A statement that is true or calls the method that we are testing. Used in a sentence: “How do I want this test to act? What function will trigger the test and provide inputs?”

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

Assert

A

Statements that verify whether the method being tested behaves as expected. Used in a sentence: “This test will assert that the data returned should be an integer.”

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

Import

A

A keyword that makes code in one module accessible in another. Used in a sentence: “I’m getting a NameError because I forgot to import the class.”

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

What are the two focus questions for our class unit tests?

A

classes and objects are responsible for tracking state and behavior. The class unit test should focus on:

1) For all relevant cases, are the attributes of an instance correct?
* *When we create an instance of this class, are the initial attributes set to what’s expected?
2) For all relevant cases, do the methods on an instance work as expected?
* *Can we call an instance method on an instance of this class, and do we observe the expected behavior?

As always, the actual test cases depend on the context of the particular class and feature. Some classes won’t have much in the way of state or behavior. Other classes will have very complex logic which will need to be thoroughly tested.

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

Module

A
Any .py file that contains functions, classes, variables, and/or other runnable code
How to Use in a Sentence:"I used the math.Euler() from the Math module to calculate an angle"
How well did you know this?
1
Not at all
2
3
4
5
Perfectly
8
Q

Package

A

A collection of modules
How to Use in a Sentence: “The requests package contains modules to help us request data from the Internet.” “My package has custom configuration in its __init__.py file.”

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