Unit testing and TDD Flashcards

1
Q

What are the levels of testing discussed in the lecture?

A

Unit Testing and System Testing.

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

What is Unit Testing?

A

Unit Testing involves testing individual components or units of a software application to ensure they work correctly.

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

Who typically performs Unit Testing?

A

Unit Testing is typically performed by developers on their own code.

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

What is System Testing?

A

System Testing involves testing the entire system as a whole to verify that it meets specified requirements.

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

Who typically performs System Testing?

A

System Testing is usually carried out by dedicated Test Engineers.

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

What is JUnit?

A

JUnit is a unit testing framework for Java, first released in 2002 by Kent Beck, Erich Gamma, David Saff, and Kris Vasudevan.

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

What version of JUnit introduced modular components?

A

JUnit 5, released in 2017, introduced modular components.

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

What is the purpose of the @BeforeEach and @AfterEach annotations in JUnit?

A

@BeforeEach runs before each test, and @AfterEach runs after each test, commonly used for setup and teardown tasks.

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

What are characteristics of a good unit test?

A

A good unit test:
- Has a descriptive name
- Tests one thing
- Always returns the same result
- Has no conditional logic
- Is independent of other tests.

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

What is code coverage?

A

Code coverage measures the degree to which the source code is executed when a test suite runs.

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

What is the recommended code coverage percentage?

A

At least 80% coverage is recommended, though 100% coverage doesn’t guarantee bug-free code.

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

What is Test Driven Development (TDD)?

A

TDD is a software development approach where tests are written before the actual code to guide development.

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

What are the steps of TDD?

A
  1. Write a failing test
    1. Write skeleton code
    2. Write enough code to pass the test.
How well did you know this?
1
Not at all
2
3
4
5
Perfectly
14
Q

What are the benefits of TDD?

A

TDD helps build testable code, reduces bugs, and improves code design and maintainability.

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

What are Test Doubles?

A

Test Doubles are substitutes for real components in a system used for testing purposes.

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

What types of Test Doubles exist?

A
  • Dummy Objects
    • Test Stubs
    • Test Spies
    • Mock Objects.
17
Q

What is the purpose of a Mock Object?

A

A Mock Object simulates the behavior of a real object and verifies interactions between components.

18
Q

What is Mockito?

A

Mockito is a popular Java mocking framework used to create mock objects for testing purposes.

19
Q

How can you verify interactions using Mockito?

A

Use the verify method to check if specific methods were called with expected parameters.

20
Q

What is a Test Pattern?

A

A Test Pattern provides a reusable solution for common testing design challenges.

21
Q

What is Dependency Injection in testing?

A

Dependency Injection involves passing dependencies to a component at runtime to make testing easier.

22
Q

What is a Dependency Lookup Pattern?

A

Dependency Lookup involves designing a system to retrieve dependencies at runtime, often using a factory pattern.