Skip to content

Commit 3779fc9

Browse files
authored
Merge pull request #1 from dorssel/tests
Add unit tests
2 parents cba4b53 + 0303e68 commit 3779fc9

File tree

7 files changed

+71
-2
lines changed

7 files changed

+71
-2
lines changed

.github/workflows/dotnet.yml

Lines changed: 16 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -45,15 +45,24 @@ jobs:
4545
4646
- name: Build
4747
run: |
48-
dotnet build --configuration Release --no-restore GitVersion.MsBuild /p:Bootstrap=true
48+
dotnet build --configuration Release --no-restore GitVersion.MsBuild -p:Bootstrap=true
4949
dotnet build --configuration Release --no-restore
5050
5151
- name: Test
52-
run: dotnet run --project Example --no-build
52+
run: |
53+
dotnet run --project Example --no-build
54+
dotnet test --configuration Release --no-build -p:TestingPlatformCommandLineArguments="--report-trx --coverage"
5355
5456
- name: Package
5557
run: dotnet pack --configuration Release --no-build
5658

59+
- name: Publish Test Results
60+
uses: EnricoMi/publish-unit-test-result-action@v2
61+
if: always()
62+
with:
63+
files: |
64+
**/TestResults/*.trx
65+
5766
- name: Upload Package Artifact
5867
uses: actions/upload-artifact@v4
5968
with:
@@ -62,3 +71,8 @@ jobs:
6271
**/*.nupkg
6372
**/*.snupkg
6473
retention-days: 14
74+
75+
- name: Codecov
76+
uses: codecov/codecov-action@v5
77+
with:
78+
token: ${{ secrets.CODECOV_TOKEN }}

UnitTests/GlobalSuppressions.cs

Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,12 @@
1+
// SPDX-FileCopyrightText: 2024 Frans van Dorsselaer
2+
//
3+
// SPDX-License-Identifier: MIT
4+
5+
// This file is used by Code Analysis to maintain SuppressMessage
6+
// attributes that are applied to this project.
7+
// Project-level suppressions either have no target or are given
8+
// a specific target and scoped to a namespace, type, member, etc.
9+
10+
using System.Diagnostics.CodeAnalysis;
11+
12+
[assembly: SuppressMessage("Performance", "CA1812:Internal class is never instantiated", Justification = "We use internal test classes")]

UnitTests/MSTestSettings.cs

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,6 @@
1+
// SPDX-FileCopyrightText: 2024 Frans van Dorsselaer
2+
//
3+
// SPDX-License-Identifier: MIT
4+
5+
[assembly: Parallelize(Scope = ExecutionScope.MethodLevel)]
6+
[assembly: DiscoverInternals]

UnitTests/Test1.cs

Lines changed: 14 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,14 @@
1+
// SPDX-FileCopyrightText: 2024 Frans van Dorsselaer
2+
//
3+
// SPDX-License-Identifier: MIT
4+
5+
namespace UnitTests;
6+
7+
[TestClass]
8+
sealed class Test1
9+
{
10+
[TestMethod]
11+
public void TestMethod1()
12+
{
13+
}
14+
}

UnitTests/UnitTests.csproj

Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,13 @@
1+
<?xml version="1.0" encoding="utf-8"?>
2+
<!--
3+
SPDX-FileCopyrightText: 2024 Frans van Dorsselaer
4+
5+
SPDX-License-Identifier: MIT
6+
-->
7+
<Project Sdk="MSTest.Sdk">
8+
9+
<PropertyGroup>
10+
<TargetFramework>net9.0</TargetFramework>
11+
</PropertyGroup>
12+
13+
</Project>

dotnet-gitversion.sln

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -15,9 +15,12 @@ Project("{2150E333-8FDC-42A3-9474-1A3956D46DE8}") = "Solution Items", "Solution
1515
Directory.Build.props = Directory.Build.props
1616
Directory.Build.targets = Directory.Build.targets
1717
Directory.Packages.props = Directory.Packages.props
18+
global.json = global.json
1819
README.md = README.md
1920
EndProjectSection
2021
EndProject
22+
Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "UnitTests", "UnitTests\UnitTests.csproj", "{E912E9B9-A821-4C5C-BDC7-12831AE93BAA}"
23+
EndProject
2124
Global
2225
GlobalSection(SolutionConfigurationPlatforms) = preSolution
2326
Debug|Any CPU = Debug|Any CPU
@@ -32,6 +35,10 @@ Global
3235
{240225EC-6BB2-4D7F-A0E8-A3070E5D5DCB}.Debug|Any CPU.Build.0 = Debug|Any CPU
3336
{240225EC-6BB2-4D7F-A0E8-A3070E5D5DCB}.Release|Any CPU.ActiveCfg = Release|Any CPU
3437
{240225EC-6BB2-4D7F-A0E8-A3070E5D5DCB}.Release|Any CPU.Build.0 = Release|Any CPU
38+
{E912E9B9-A821-4C5C-BDC7-12831AE93BAA}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
39+
{E912E9B9-A821-4C5C-BDC7-12831AE93BAA}.Debug|Any CPU.Build.0 = Debug|Any CPU
40+
{E912E9B9-A821-4C5C-BDC7-12831AE93BAA}.Release|Any CPU.ActiveCfg = Release|Any CPU
41+
{E912E9B9-A821-4C5C-BDC7-12831AE93BAA}.Release|Any CPU.Build.0 = Release|Any CPU
3542
EndGlobalSection
3643
GlobalSection(SolutionProperties) = preSolution
3744
HideSolutionNode = FALSE

global.json

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -3,5 +3,8 @@
33
"version": "9.0.100",
44
"allowPrerelease": false,
55
"rollForward": "latestFeature"
6+
},
7+
"msbuild-sdks": {
8+
"MSTest.Sdk": "3.6.3"
69
}
710
}

0 commit comments

Comments
 (0)