Unit Testing & Quality Assurance Flashcards

1
Q

What is unit testing, and why is it important?

A

Unit testing verifies individual components of your code (usually functions or classes) in isolation to ensure they work as expected. It’s important because it catches bugs early, makes refactoring easier, and improves code reliability.

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

How do you mock dependencies in unit tests for .NET applications?

A

In .NET, mocking dependencies is typically done using libraries like Moq. By injecting interfaces into classes via dependency injection, you can mock these interfaces to control the behavior of external services during testing.

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

What is the difference between unit testing and integration testing?

A

Unit Testing: Tests individual components in isolation (e.g., a function).
Integration Testing: Tests how multiple components interact together, such as testing a controller that interacts with a service and a database.

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

Can you describe the Arrange-Act-Assert pattern used in unit testing?

A

This is a common pattern for structuring tests:
Arrange: Set up the test data and mocks.
Act: Execute the function being tested.
Assert: Verify that the outcome matches the expected result.

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