Add NUnit XML results fixtures

This commit is contained in:
Michal Dorner 2021-06-28 22:24:27 +02:00 committed by Jozef Izso
parent 78ed680850
commit b34d4b1bfe
6 changed files with 327 additions and 0 deletions

View file

@ -0,0 +1,64 @@
using System;
using System.Threading;
using DotnetTests.Unit;
using NUnit.Framework;
namespace DotnetTests.XUnitTests
{
public class CalculatorTests
{
private readonly Calculator _calculator = new Calculator();
[Test]
public void Passing_Test()
{
Assert.That(_calculator.Sum(1, 1), Is.EqualTo(2));
}
[Test(Description = "Some description")]
public void Passing_Test_With_Description()
{
Assert.That(2, Is.EqualTo(2));
}
[Test]
public void Failing_Test()
{
Assert.That(_calculator.Sum(1, 1), Is.EqualTo(3));
}
[Test]
public void Exception_In_TargetTest()
{
_calculator.Div(1, 0);
}
[Test]
public void Exception_In_Test()
{
throw new Exception("Test");
}
[Test]
[Timeout(1)]
public void Timeout_Test()
{
Thread.Sleep(100);
}
[Test]
[Ignore("Skipped")]
public void Skipped_Test()
{
throw new Exception("Test");
}
[Theory]
[TestCase(2)]
[TestCase(3)]
public void Is_Even_Number(int i)
{
Assert.True(i % 2 == 0);
}
}
}

View file

@ -0,0 +1,18 @@
<Project Sdk="Microsoft.NET.Sdk">
<PropertyGroup>
<TargetFramework>netcoreapp3.1</TargetFramework>
<IsPackable>false</IsPackable>
</PropertyGroup>
<ItemGroup>
<PackageReference Include="NUnit" Version="3.13.2" />
<PackageReference Include="Microsoft.NET.Test.Sdk" Version="16.5.0" />
</ItemGroup>
<ItemGroup>
<ProjectReference Include="..\DotnetTests.Unit\DotnetTests.Unit.csproj" />
</ItemGroup>
</Project>