Skip to content

Commit 38ecdda

Browse files
committed
feat: Added TUnit template
1 parent 6728ad2 commit 38ecdda

File tree

5 files changed

+36
-6
lines changed

5 files changed

+36
-6
lines changed

src/bunit.template/bunit.template.csproj

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -41,4 +41,8 @@
4141
<None Remove="template\CounterRazorTests.razor" />
4242
</ItemGroup>
4343

44+
<ItemGroup>
45+
<Folder Include="temp\" />
46+
</ItemGroup>
47+
4448
</Project>

src/bunit.template/template/.template.config/dotnetcli.host.json

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -17,6 +17,7 @@
1717
"--framework xunit --sdk net8.0",
1818
"--framework xunitv3 --sdk net8.0",
1919
"--framework nunit --sdk net8.0",
20-
"--framework mstest --sdk net8.0"
20+
"--framework mstest --sdk net8.0",
21+
"--framework tunit --sdk net8.0"
2122
]
2223
}

src/bunit.template/template/.template.config/template.json

Lines changed: 11 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -23,8 +23,8 @@
2323
{
2424
"modifiers": [
2525
{
26-
"exclude": [ "BunitTestContext.cs" ],
27-
"condition": "(testFramework_xunit || testFramework_xunitv3)"
26+
"exclude": [ "_Imports.razor", "CounterRazorTests.razor" ],
27+
"condition": "(testFramework_tunit)"
2828
}
2929
]
3030
}
@@ -67,6 +67,11 @@
6767
"choice": "mstest",
6868
"description": "MSTest unit testing framework",
6969
"displayName": "MSTest"
70+
},
71+
{
72+
"choice": "tunit",
73+
"description": "TUnit unit testing framework",
74+
"displayName": "TUnit"
7075
}
7176
]
7277
},
@@ -86,6 +91,10 @@
8691
"type": "computed",
8792
"value": "UnitTestFramework == \"mstest\""
8893
},
94+
"testFramework_tunit": {
95+
"type": "computed",
96+
"value": "UnitTestFramework == \"tunit\""
97+
},
8998
"targetSdk": {
9099
"type": "parameter",
91100
"description": "The target framework sdk for the project.",

src/bunit.template/template/Company.BlazorTests1.csproj

Lines changed: 12 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,9 +1,14 @@
1+
<!--#if (testFramework_tunit) -->
2+
<Project Sdk="Microsoft.NET.Sdk">
3+
<!--#else -->
14
<Project Sdk="Microsoft.NET.Sdk.Razor">
2-
5+
<!--#endif -->
36
<PropertyGroup>
47
<TargetFramework>targetSdk</TargetFramework>
58
<Nullable>enable</Nullable>
69
<IsPackable>false</IsPackable>
10+
<OutputType Condition="'$(testFramework_tunit)' == 'true'">Exe</OutputType>
11+
<IsTestingPlatformApplication Condition="'$(testFramework_tunit)' == 'true'">false</IsTestingPlatformApplication>
712
</PropertyGroup>
813

914
<ItemGroup>
@@ -18,8 +23,8 @@
1823

1924
<ItemGroup>
2025
<PackageReference Include="bunit" Version="#{RELEASE_VERSION}#" />
21-
<PackageReference Include="Microsoft.NET.Test.Sdk" Version="17.12.0" />
22-
<PackageReference Include="coverlet.collector" Version="6.0.3">
26+
<PackageReference Include="Microsoft.NET.Test.Sdk" Version="17.12.0" Condition="'$(testFramework_tunit)' != 'true'"/>
27+
<PackageReference Include="coverlet.collector" Version="6.0.3" Condition="'$(testFramework_tunit)' != 'true'">
2328
<IncludeAssets>runtime; build; native; contentfiles; analyzers; buildtransitive</IncludeAssets>
2429
<PrivateAssets>all</PrivateAssets>
2530
</PackageReference>
@@ -51,4 +56,8 @@
5156
<PackageReference Include="MSTest.TestFramework" Version="3.6.4" />
5257
</ItemGroup>
5358

59+
<ItemGroup Condition="'$(testFramework_tunit)' == 'true'">
60+
<PackageReference Include="TUnit" Version="0.6.154" />
61+
</ItemGroup>
62+
5463
</Project>

src/bunit.template/template/CounterCSharpTest.cs

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,7 @@
1+
#if (testFramework_tunit)
2+
using TUnit;
3+
#endif
4+
15
namespace Company.BlazorTests1;
26

37
/// <summary>
@@ -14,6 +18,9 @@ public class CounterCSharpTest : BunitContext
1418
#elif (testFramework_mstest)
1519
[TestClass]
1620
public class CounterCSharpTest : BunitContext
21+
#elif (testFramework_tunit)
22+
[Test]
23+
public class CounterCSharpTest : BunitContext
1724
#endif
1825
{
1926
#if (testFramework_xunit)

0 commit comments

Comments
 (0)