# 단위 테스트와 xUnit (.NET) > xUnit 프레임워크, 테스트 케이스, assertions, Moq, FluentAssertions, 코드 커버리지, TDD 원칙 - 20 면접 질문 - Mid-Level - [면접 질문: .NET](https://sharpskill.dev/ko/technologies/dotnet/interview-questions.md) ## 1. .NET 맥락에서 xUnit이란 무엇입니까? **답변** xUnit은 JUnit과 NUnit에서 영감을 받은 .NET용 오픈 소스 단위 테스트 프레임워크입니다. 간단한 테스트에는 [Fact], 매개변수화된 테스트에는 [Theory]와 같은 어트리뷰트를 사용합니다. xUnit은 테스트 격리(각 테스트가 새로운 테스트 클래스 인스턴스를 생성)와 같은 모범 사례를 권장하며 전통적인 Setup/Teardown 메서드를 통한 공유 상태를 피합니다. ## 2. xUnit에서 [Fact]와 [Theory]의 차이점은 무엇입니까? **답변** [Fact]는 매개변수 없이 한 번 실행되는 간단한 테스트를 데코레이션하고, [Theory]는 [InlineData], [MemberData] 또는 [ClassData]를 통해 제공되는 다양한 값으로 여러 번 실행되는 매개변수화된 테스트를 데코레이션합니다. [Theory]를 사용하면 서로 다른 데이터로 여러 유사한 시나리오를 테스트할 때 코드 중복을 피할 수 있습니다. ## 3. xUnit에서 [InlineData]를 [Theory]와 함께 어떻게 사용합니까? **답변** [InlineData]는 [Theory] 테스트를 위해 어트리뷰트 내에서 데이터를 직접 제공하여 동일한 테스트를 다른 값으로 실행할 수 있게 합니다. 각 [InlineData] 어트리뷰트는 별개의 테스트 케이스를 나타냅니다. 이 방식은 별도의 데이터 클래스를 만들지 않고 여러 간단한 시나리오를 테스트하는 데 이상적이며 boilerplate 코드를 줄여줍니다. ## 17개 추가 질문 이용 가능 - .NET 단위 테스트에서 Moq의 주요 장점은 무엇입니까? - 메서드가 특정 값을 반환하도록 Moq으로 mock을 어떻게 구성합니까? 무료로 가입하기: https://sharpskill.dev/ko/login ## 기타 .NET 면접 주제 - [C# 기초](https://sharpskill.dev/ko/technologies/dotnet/interview-questions/csharp-basics.md): 25개 질문, Junior - [LINQ & Delegates](https://sharpskill.dev/ko/technologies/dotnet/interview-questions/csharp-linq-delegates.md): 20개 질문, Junior - [C# 언어 핵심 요소](https://sharpskill.dev/ko/technologies/dotnet/interview-questions/csharp-language-essentials.md): 15개 질문, Junior - [ASP.NET Core 기초](https://sharpskill.dev/ko/technologies/dotnet/interview-questions/aspnet-core-fundamentals.md): 18개 질문, Junior - [ASP.NET Core 요청 수명 주기](https://sharpskill.dev/ko/technologies/dotnet/interview-questions/aspnet-core-request-lifecycle.md): 20개 질문, Junior - [Configuration & Settings](https://sharpskill.dev/ko/technologies/dotnet/interview-questions/configuration-settings.md): 20개 질문, Junior - [애플리케이션 라이프사이클](https://sharpskill.dev/ko/technologies/dotnet/interview-questions/application-lifecycle.md): 20개 질문, Junior - [Dependency Injection](https://sharpskill.dev/ko/technologies/dotnet/interview-questions/dependency-injection.md): 24개 질문, Mid-Level - [Entity Framework Core](https://sharpskill.dev/ko/technologies/dotnet/interview-questions/entity-framework-core.md): 25개 질문, Mid-Level - [Minimal APIs](https://sharpskill.dev/ko/technologies/dotnet/interview-questions/minimal-apis.md): 18개 질문, Mid-Level - [Web API 개발](https://sharpskill.dev/ko/technologies/dotnet/interview-questions/web-api-development.md): 22개 질문, Mid-Level - [ASP.NET Core의 Async](https://sharpskill.dev/ko/technologies/dotnet/interview-questions/async-aspnet-core.md): 20개 질문, Mid-Level - [Authentication & Authorization](https://sharpskill.dev/ko/technologies/dotnet/interview-questions/authentication-authorization.md): 18개 질문, Mid-Level - [HttpClient & 네트워킹](https://sharpskill.dev/ko/technologies/dotnet/interview-questions/httpclient-networking.md): 20개 질문, Mid-Level - [JSON 직렬화](https://sharpskill.dev/ko/technologies/dotnet/interview-questions/json-serialization.md): 20개 질문, Mid-Level - [Entity Framework Core 고급](https://sharpskill.dev/ko/technologies/dotnet/interview-questions/ef-core-advanced.md): 25개 질문, Mid-Level - [C# 고급 기능](https://sharpskill.dev/ko/technologies/dotnet/interview-questions/csharp-advanced-features.md): 20개 질문, Mid-Level - [Clean Architecture](https://sharpskill.dev/ko/technologies/dotnet/interview-questions/clean-architecture.md): 20개 질문, Mid-Level - [Logging, Monitoring & Observability](https://sharpskill.dev/ko/technologies/dotnet/interview-questions/logging-monitoring.md): 22개 질문, Mid-Level - [통합 테스트](https://sharpskill.dev/ko/technologies/dotnet/interview-questions/integration-testing.md): 18개 질문, Mid-Level - [Docker & Containerization](https://sharpskill.dev/ko/technologies/dotnet/interview-questions/docker-containerization.md): 16개 질문, Mid-Level - [NuGet 패키지 관리](https://sharpskill.dev/ko/technologies/dotnet/interview-questions/nuget-package-management.md): 16개 질문, Mid-Level - [Memory Management & GC](https://sharpskill.dev/ko/technologies/dotnet/interview-questions/memory-management-gc.md): 22개 질문, Senior - [리액티브 프로그래밍](https://sharpskill.dev/ko/technologies/dotnet/interview-questions/reactive-programming.md): 24개 질문, Senior - [Async/await 및 패턴](https://sharpskill.dev/ko/technologies/dotnet/interview-questions/async-await-patterns.md): 26개 질문, Senior - [.NET 디자인 패턴](https://sharpskill.dev/ko/technologies/dotnet/interview-questions/dotnet-design-patterns.md): 24개 질문, Senior - [성능 최적화](https://sharpskill.dev/ko/technologies/dotnet/interview-questions/performance-optimization.md): 22개 질문, Senior - [보안 및 모범 사례](https://sharpskill.dev/ko/technologies/dotnet/interview-questions/security-best-practices.md): 24개 질문, Senior - [SignalR 및 실시간](https://sharpskill.dev/ko/technologies/dotnet/interview-questions/signalr-realtime.md): 22개 질문, Senior - [마이크로서비스 아키텍처](https://sharpskill.dev/ko/technologies/dotnet/interview-questions/microservices-architecture.md): 25개 질문, Senior --- Source: SharpSkill (https://sharpskill.dev), tech interview preparation for your real stack. HTML version of this page: https://sharpskill.dev/ko/technologies/dotnet/interview-questions/unit-testing-xunit