Ch6: Unit Testing Flashcards

1
Q

Benefits of Testing

A
  1. Living documentation that is updated with codebase
  2. Ensures expected and consistent behavior
  3. Safeguard against creation of bugs during refactoring
How well did you know this?
1
Not at all
2
3
4
5
Perfectly
2
Q

Define Unit Testing

A

Breaks codebase into smallest building blocks: individual statements and methods. This form of automated testing addresses fundamental tasks of classes.

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

Name a common unit testing framework for Java

A

JUnit

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

Define Refactoring

A

Process of rewriting code without introducing new features

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

Name the Testing Best Practices

A
  1. AAAs
  2. Deterministic
  3. Relevant
  4. Meaningful
How well did you know this?
1
Not at all
2
3
4
5
Perfectly
6
Q

Define the AAAs testing best practice

A

Pattern to follow when writing tests

  1. ARRANGE variables
  2. ACT on methods
  3. ASSERT comparison of expected & actual values
How well did you know this?
1
Not at all
2
3
4
5
Perfectly
7
Q

Define the Deterministic testing best practice

A

Produce same outcome every run

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

Define the Relevant testing best practice

A

Group by related class and function

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

Define the Meaningful testing best practice

A

Don’t test trivial code (ex. getters/setters)

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

Describe JUnit

A

A commonly used Java testing framework. This library provides classes, methods, and assertions for writing an executing unit test.

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

Define Java Annotation

A

Formalized information about program that doesn’t directly affect code, but supplies directions to the compiler. Use @ symbol

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

@Test

A

Annotation indicating public void method is a test case

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

@Before

A

Annotated method setting up data or conditions that will be provided to every test in a class. (ex: creating instances of objects)

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

@After

A

Annotated method setting up conditions to meet after all tests in a suite are finished running. (ex: closing database connection)

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

List 4 Common Assertion Methods

A

assertEquals, assertFalse, assertTrue, assertNotNull

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

assertEquals(expected, actual, optional_delta)

A

Asserts that two values, expected and actual, are equal to each other (optionally, within a given range of difference)

17
Q

assertFalse(condition)

A

Asserts that a given condition is false

18
Q

assertTrue(condition)

A

Asserts that a given condition is true

19
Q

assertNotNull(object)

A

Asserts that a given object is not null

20
Q

Define JAR

A

Java Archive (.jar) files are a common Java file format used for bundling classes and files together

21
Q

Define dependancy

A

Separately developed program/code that current project utilizes to carry out its function

22
Q

Define delta and list a data type that you should use them with

A

Amount of allowed difference between expected & actual value. Required for doubles, because they are floating-point #s