Master technical and career interviews with structured answers—short definition, real examples, pitfalls, and how to answer in 60–90 seconds.
Answer: Code coverage measures the percentage of code executed by tests. It helps identify untested parts but doesn’t guarantee test quality. High coverage with meaningful tests improves confidence in code correctness. x…
xUnit is a free, open-source unit testing framework for .NET, designed by the original uthors of NUnit. It’s popular because it supports modern testing practices, is lightweight, extensible, integrates well with .NET Cor…
xUnit encourages constructor injection for setup instead of [SetUp] methods. It uses [Fact] and [Theory] attributes for test methods, while NUnit/MSTest use [Test] and [TestMethod]. xUnit does not use [TestInitialize]/[T…
Answer: public class CalculatorTests { [Fact] public void Add_ReturnsSum() { var calculator = new Calculator(); var result = calculator.Add(2, 3); ssert.Equal(5, result); } } What interviewers expect A clear definition t…
Answer: [Fact]: Defines a parameterless test method representing a single test case. [Theory]: Defines a parameterized test that runs multiple times with different data inputs, provided by [InlineData] or other data sour…
Using [Theory] and data attributes like [InlineData]: [Theory] [InlineData(2, 3, 5)] [InlineData(10, 20, 30)] public void Add_ReturnsSum(int a, int b, int expected) { var calculator = new Calculator(); var result = calcu…
Use the constructor for setup code. Implement IDisposable interface for teardown (cleanup) code. Example: public class DatabaseTests : IDisposable { public DatabaseTests() { // Setup } [Fact] public void TestMethod() { }…
Answer: Use the Skip property on [Fact] or [Theory]: [Fact(Skip = "Reason for skipping")] public void SkippedTest() { } What interviewers expect A clear definition tied to Testing in Unit Testing projects Trade-offs (per…
Group related tests in the same class. Use Collection attribute to group classes that share setup/teardown or should not run in parallel. [Collection("Database collection")] public class TestClass1 { } [Collection("Datab…
Test fixtures provide a way to share setup and cleanup code between tests. xUnit supports: Class Fixtures: Shared across all tests in a class. Collection Fixtures: Shared across multiple test classes. They are implemente…
Answer: Use the dotnet test CLI command: dotnet test YourTestProject.csproj This runs all tests in the project and outputs results in the console. Additional options allow filtering and outputting reports. NUnit Framewor…
NUnit is a popular open-source unit testing framework for .NET. It allows developers to write nd run automated tests by marking test methods with attributes. NUnit discovers and executes these tests, verifying that the c…
NUnit uses [Test] for test methods, whereas xUnit uses [Fact]. NUnit uses [SetUp] and [TearDown] for setup and cleanup, while xUnit uses constructors and IDisposable. NUnit supports [TestCase] for parameterized tests, xU…
Answer: [TestCase(2, 3, 5)] [TestCase(10, 20, 30)] public void Add_ReturnsSum(int a, int b, int expected) { var calculator = new Calculator(); var result = calculator.Add(a, b); ssert.AreEqual(expected, result); } What i…
Answer: [SetUp] runs code before each test method to prepare test environment. [TearDown] runs code after each test to clean up resources or reset state. What interviewers expect A clear definition tied to Testing in Uni…
Answer: [Test] public void Divide_ByZero_ThrowsException() { var calculator = new Calculator(); ssert.Throws<DivideByZeroException>(() => calculator.Divide(10, 0)); } What interviewers expect A clear…
Answer: Use the [Category("CategoryName")] attribute to group tests, allowing filtering by category during test runs. [Test, Category("Integration")] public void IntegrationTest() { } What interviewers expect A clear def…
Answer: [Test] marks a standard test method without parameters. [TestCase] provides inline parameter values to run the test multiple times with different inputs. What interviewers expect A clear definition tied to Testin…
Answer: Use [Ignore("Reason")] to skip tests unconditionally, or [Category] combined with test runner filters. For conditional ignoring, you can use Assume statements or custom logic inside tests. What interviewers expec…
Answer: Download and use nunit3-console.exe from NUnit site: nunit3-console.exe YourTestAssembly.dll It runs all tests in the assembly and outputs results. What interviewers expect A clear definition tied to Testing in U…
Answer: Yes, NUnit integrates seamlessly with CI/CD tools like Azure DevOps, Jenkins, GitHub ctions, and others using command-line runners or plugins, allowing automated test execution during builds and deployments. MSTe…
MSTest is Microsoft's official unit testing framework for .NET. It’s tightly integrated with Visual Studio and is a good choice for teams using Microsoft tooling and wanting a straightforward, supported testing solution…
Answer: [TestClass] public class CalculatorTests { [TestMethod] public void Add_ReturnsSum() { var calculator = new Calculator(); var result = calculator.Add(2, 3); ssert.AreEqual(5, result); } } What interviewers expect…
MSTest is Microsoft's official framework; NUnit and xUnit are community-driven. MSTest uses [TestClass] and [TestMethod] attributes; xUnit uses [Fact], NUnit uses [Test]. MSTest has less flexibility in data-driven tests…
ttributes? [TestInitialize] runs code before each test method to set up prerequisites. [TestCleanup] runs after each test method to clean up resources. [TestInitialize] public void Setup() { /* setup code */ } [TestClean…
Unit Testing C# Programming Tutorial · Testing
Answer: Code coverage measures the percentage of code executed by tests. It helps identify untested parts but doesn’t guarantee test quality. High coverage with meaningful tests improves confidence in code correctness. xUnit Framework
In a production Unit Testing application, teams apply this when handling user-facing features or integration boundaries. For example, you might use it during a sprint where reliability and observability matter—logging metrics, validating edge cases, and documenting the decision in an ADR so future developers understand why the approach was chosen.
Tip: Practice aloud on Toolliyo mock interview or the Interview Q&A section before your real interview.
Unit Testing C# Programming Tutorial · Testing
xUnit is a free, open-source unit testing framework for .NET, designed by the original
uthors of NUnit. It’s popular because it supports modern testing practices, is lightweight,
extensible, integrates well with .NET Core and Visual Studio, and encourages clean,
maintainable test code.
Unit Testing C# Programming Tutorial · Testing
[Test] and [TestMethod].
nd constructor/dispose patterns.
default.
Unit Testing C# Programming Tutorial · Testing
Answer: public class CalculatorTests { [Fact] public void Add_ReturnsSum() { var calculator = new Calculator(); var result = calculator.Add(2, 3); ssert.Equal(5, result); } }
In a production Unit Testing application, teams apply this when handling user-facing features or integration boundaries. For example, you might use it during a sprint where reliability and observability matter—logging metrics, validating edge cases, and documenting the decision in an ADR so future developers understand why the approach was chosen.
Tip: Practice aloud on Toolliyo mock interview or the Interview Q&A section before your real interview.
Unit Testing C# Programming Tutorial · Testing
Answer: [Fact]: Defines a parameterless test method representing a single test case. [Theory]: Defines a parameterized test that runs multiple times with different data inputs, provided by [InlineData] or other data sources.
In a production Unit Testing application, teams apply this when handling user-facing features or integration boundaries. For example, you might use it during a sprint where reliability and observability matter—logging metrics, validating edge cases, and documenting the decision in an ADR so future developers understand why the approach was chosen.
Tip: Practice aloud on Toolliyo mock interview or the Interview Q&A section before your real interview.
Unit Testing C# Programming Tutorial · Testing
Using [Theory] and data attributes like [InlineData]:
[Theory]
[InlineData(2, 3, 5)]
[InlineData(10, 20, 30)]
public void Add_ReturnsSum(int a, int b, int expected)
{
var calculator = new Calculator();
var result = calculator.Add(a, b);
ssert.Equal(expected, result);
}Unit Testing C# Programming Tutorial · Testing
Example:
public class DatabaseTests : IDisposable
{
public DatabaseTests()
{
// Setup
}
[Fact]
public void TestMethod() { }
public void Dispose()
{
// Cleanup
}
}
For shared context across multiple tests, use class fixtures or collection fixtures.Unit Testing C# Programming Tutorial · Testing
Answer: Use the Skip property on [Fact] or [Theory]: [Fact(Skip = "Reason for skipping")] public void SkippedTest() { }
In a production Unit Testing application, teams apply this when handling user-facing features or integration boundaries. For example, you might use it during a sprint where reliability and observability matter—logging metrics, validating edge cases, and documenting the decision in an ADR so future developers understand why the approach was chosen.
Tip: Practice aloud on Toolliyo mock interview or the Interview Q&A section before your real interview.
Unit Testing C# Programming Tutorial · Testing
run in parallel.
[Collection("Database collection")]
public class TestClass1 { }
[Collection("Database collection")]
public class TestClass2 { }Unit Testing C# Programming Tutorial · Testing
Test fixtures provide a way to share setup and cleanup code between tests. xUnit supports:
They are implemented by creating a fixture class and injecting it into test classes via
constructor.
Unit Testing C# Programming Tutorial · Testing
Answer: Use the dotnet test CLI command: dotnet test YourTestProject.csproj This runs all tests in the project and outputs results in the console. Additional options allow filtering and outputting reports. NUnit Framework
In a production Unit Testing application, teams apply this when handling user-facing features or integration boundaries. For example, you might use it during a sprint where reliability and observability matter—logging metrics, validating edge cases, and documenting the decision in an ADR so future developers understand why the approach was chosen.
Tip: Practice aloud on Toolliyo mock interview or the Interview Q&A section before your real interview.
Unit Testing C# Programming Tutorial · Testing
NUnit is a popular open-source unit testing framework for .NET. It allows developers to write
nd run automated tests by marking test methods with attributes. NUnit discovers and
executes these tests, verifying that the code behaves as expected.
Unit Testing C# Programming Tutorial · Testing
constructors and IDisposable.
[InlineData].
Unit Testing C# Programming Tutorial · Testing
Answer: [TestCase(2, 3, 5)] [TestCase(10, 20, 30)] public void Add_ReturnsSum(int a, int b, int expected) { var calculator = new Calculator(); var result = calculator.Add(a, b); ssert.AreEqual(expected, result); }
In a production Unit Testing application, teams apply this when handling user-facing features or integration boundaries. For example, you might use it during a sprint where reliability and observability matter—logging metrics, validating edge cases, and documenting the decision in an ADR so future developers understand why the approach was chosen.
Tip: Practice aloud on Toolliyo mock interview or the Interview Q&A section before your real interview.
Unit Testing C# Programming Tutorial · Testing
Answer: [SetUp] runs code before each test method to prepare test environment. [TearDown] runs code after each test to clean up resources or reset state.
In a production Unit Testing application, teams apply this when handling user-facing features or integration boundaries. For example, you might use it during a sprint where reliability and observability matter—logging metrics, validating edge cases, and documenting the decision in an ADR so future developers understand why the approach was chosen.
Tip: Practice aloud on Toolliyo mock interview or the Interview Q&A section before your real interview.
Unit Testing C# Programming Tutorial · Testing
Answer: [Test] public void Divide_ByZero_ThrowsException() { var calculator = new Calculator(); ssert.Throws<DivideByZeroException>(() => calculator.Divide(10, 0)); }
In a production Unit Testing application, teams apply this when handling user-facing features or integration boundaries. For example, you might use it during a sprint where reliability and observability matter—logging metrics, validating edge cases, and documenting the decision in an ADR so future developers understand why the approach was chosen.
Tip: Practice aloud on Toolliyo mock interview or the Interview Q&A section before your real interview.
Unit Testing C# Programming Tutorial · Testing
Answer: Use the [Category("CategoryName")] attribute to group tests, allowing filtering by category during test runs. [Test, Category("Integration")] public void IntegrationTest() { }
In a production Unit Testing application, teams apply this when handling user-facing features or integration boundaries. For example, you might use it during a sprint where reliability and observability matter—logging metrics, validating edge cases, and documenting the decision in an ADR so future developers understand why the approach was chosen.
Tip: Practice aloud on Toolliyo mock interview or the Interview Q&A section before your real interview.
Unit Testing C# Programming Tutorial · Testing
Answer: [Test] marks a standard test method without parameters. [TestCase] provides inline parameter values to run the test multiple times with different inputs.
In a production Unit Testing application, teams apply this when handling user-facing features or integration boundaries. For example, you might use it during a sprint where reliability and observability matter—logging metrics, validating edge cases, and documenting the decision in an ADR so future developers understand why the approach was chosen.
Tip: Practice aloud on Toolliyo mock interview or the Interview Q&A section before your real interview.
Unit Testing C# Programming Tutorial · Testing
Answer: Use [Ignore("Reason")] to skip tests unconditionally, or [Category] combined with test runner filters. For conditional ignoring, you can use Assume statements or custom logic inside tests.
In a production Unit Testing application, teams apply this when handling user-facing features or integration boundaries. For example, you might use it during a sprint where reliability and observability matter—logging metrics, validating edge cases, and documenting the decision in an ADR so future developers understand why the approach was chosen.
Tip: Practice aloud on Toolliyo mock interview or the Interview Q&A section before your real interview.
Unit Testing C# Programming Tutorial · Testing
Answer: Download and use nunit3-console.exe from NUnit site: nunit3-console.exe YourTestAssembly.dll It runs all tests in the assembly and outputs results.
In a production Unit Testing application, teams apply this when handling user-facing features or integration boundaries. For example, you might use it during a sprint where reliability and observability matter—logging metrics, validating edge cases, and documenting the decision in an ADR so future developers understand why the approach was chosen.
Tip: Practice aloud on Toolliyo mock interview or the Interview Q&A section before your real interview.
Unit Testing C# Programming Tutorial · Testing
Answer: Yes, NUnit integrates seamlessly with CI/CD tools like Azure DevOps, Jenkins, GitHub ctions, and others using command-line runners or plugins, allowing automated test execution during builds and deployments. MSTest Framework
In a production Unit Testing application, teams apply this when handling user-facing features or integration boundaries. For example, you might use it during a sprint where reliability and observability matter—logging metrics, validating edge cases, and documenting the decision in an ADR so future developers understand why the approach was chosen.
Tip: Practice aloud on Toolliyo mock interview or the Interview Q&A section before your real interview.
Unit Testing C# Programming Tutorial · Testing
MSTest is Microsoft's official unit testing framework for .NET. It’s tightly integrated with
Visual Studio and is a good choice for teams using Microsoft tooling and wanting a
straightforward, supported testing solution without external dependencies.
Unit Testing C# Programming Tutorial · Testing
Answer: [TestClass] public class CalculatorTests { [TestMethod] public void Add_ReturnsSum() { var calculator = new Calculator(); var result = calculator.Add(2, 3); ssert.AreEqual(5, result); } }
In a production Unit Testing application, teams apply this when handling user-facing features or integration boundaries. For example, you might use it during a sprint where reliability and observability matter—logging metrics, validating edge cases, and documenting the decision in an ADR so future developers understand why the approach was chosen.
Tip: Practice aloud on Toolliyo mock interview or the Interview Q&A section before your real interview.
Unit Testing C# Programming Tutorial · Testing
NUnit uses [Test].
xUnit’s [Theory].
Unit Testing C# Programming Tutorial · Testing
ttributes?
[TestInitialize]
public void Setup() { /* setup code */ }
[TestCleanup]
public void Cleanup() { /* cleanup code */ }