Unit Test
Wahid Abduhakimov
Unit Testlar nega kerak?
Unit Testlar nega kerak?Unit Testlar qanday yoziladi?
Unit Testlar qanday yoziladi?using Xunit;
public class CalculatorTests
{
[Fact]
public void Add_WithPositiveNumbers_ReturnsCorrectSum()
{
// Arrange
var calculator = new Calculator();
int a = 2;
int b = 3;
// Act
int result = calculator.Add(a, b);
// Assert
Assert.Equal(5, result);
}
}
public class Calculator
{
public int Add(int a, int b)
{
return a + b;
}
}Best Practicelar
Best Practicelar1. Alohida ajratilgan testlar yozish
2. Ma’noli nomlar berish
3. Test freymvorklar ishlatish
4. Mock va Stub’lar ishlatish
5. Hamma holatlarni testlash
6. Readable test yozish
Last updated
Was this helpful?