
Integration Testing
WebApplicationFactory, TestServer, database testing, HTTP client testing, test fixtures
1What is WebApplicationFactory in ASP.NET Core?
What is WebApplicationFactory in ASP.NET Core?
Risposta
WebApplicationFactory is a class provided by the Microsoft.AspNetCore.Mvc.Testing package that allows creating an in-memory test server for integration testing. It initializes the ASP.NET Core application with all its dependencies without requiring actual deployment, making tests fast and isolated. This approach is recommended because it tests the application in an environment close to production while avoiding the setup costs of a real server.
2What is the main advantage of using WebApplicationFactory instead of a real HTTP server in integration tests?
What is the main advantage of using WebApplicationFactory instead of a real HTTP server in integration tests?
Risposta
WebApplicationFactory creates an in-memory test server, which eliminates network latency and deployment costs while providing full control over configuration. Tests execute much faster because there's no real network communication or separate process to manage. Additionally, services can be replaced via ConfigureTestServices, which facilitates test isolation and simulation of different scenarios without external infrastructure.
3What is the difference between a unit test and an integration test in ASP.NET Core?
What is the difference between a unit test and an integration test in ASP.NET Core?
Risposta
Unit tests isolate and test a single unit of code (method, class) by mocking all dependencies, while integration tests verify that multiple components work together correctly, including the database, middleware, and real services. Unit tests are faster and simpler but don't detect integration issues, while integration tests are slower but validate the application's overall behavior. A balanced strategy combines both approaches.
Which NuGet package is required to use WebApplicationFactory in integration tests?
How to create an HTTP client to test an API with WebApplicationFactory?
+15 domande da colloquio
Altri argomenti di colloquio .NET
C# Basics
LINQ & Delegates
C# Language Essentials
ASP.NET Core Fundamentals
ASP.NET Core Request Lifecycle
Configuration & Settings
Application Lifecycle
Dependency Injection
Entity Framework Core
Minimal APIs
Web API Development
Async in ASP.NET Core
Authentication & Authorization
HttpClient & Networking
JSON Serialization
Entity Framework Core Advanced
C# Advanced Features
Clean Architecture
Logging, Monitoring & Observability
Unit Testing & xUnit
Docker & Containerization
NuGet Package Management
Memory Management & GC
Reactive Programming
Async/await & Patterns
.NET Design Patterns
Performance Optimization
Security & Best Practices
SignalR & Real-time
Microservices Architecture
Padroneggia .NET per il tuo prossimo colloquio
Accedi a tutte le domande, flashcards, test tecnici, esercizi di code review e simulatori di colloquio.
Inizia gratis