Skip to content

Commit 88dc42c

Browse files
author
Gonzalo Diaz
committed

File tree

5 files changed

+37
-9
lines changed

5 files changed

+37
-9
lines changed

.gitignore

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -135,3 +135,8 @@ _NCrunch*
135135
# VSCode C# Dev Kit
136136

137137
.mono
138+
139+
# Coverage
140+
coverage.cobertura.xml
141+
coverage.json
142+
lcov.info

Makefile

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -79,7 +79,7 @@ build: env dependencies
7979
${PACKAGE_TOOL} build --verbosity ${VERBOSITY_LEVEL}
8080

8181
test: build
82-
${PACKAGE_TOOL} test --verbosity ${VERBOSITY_LEVEL}
82+
${PACKAGE_TOOL} test --verbosity ${VERBOSITY_LEVEL} --collect:"Code Coverage"
8383

8484
coverage: dependencies
8585

algorithm-exercises-csharp/algorithm-exercises-csharp.csproj

Lines changed: 12 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -8,14 +8,25 @@
88

99
<IsPackable>false</IsPackable>
1010
<IsTestProject>true</IsTestProject>
11-
<!---->
11+
12+
<!-- Coverage -->
13+
<CollectCoverage>true</CollectCoverage>
14+
<CoverletOutputFormat>lcov</CoverletOutputFormat>
15+
<CoverletOutput>./lcov.info</CoverletOutput>
16+
<IncludeTestAssembly>true</IncludeTestAssembly>
17+
18+
<!-- Static Analysis -->
1219
<EnableNETAnalyzers>true</EnableNETAnalyzers>
1320
<EnforceCodeStyleInBuild>true</EnforceCodeStyleInBuild>
1421
<CodeAnalysisTreatWarningsAsErrors>false</CodeAnalysisTreatWarningsAsErrors>
1522
</PropertyGroup>
1623

1724
<ItemGroup>
1825
<PackageReference Include="coverlet.collector" Version="6.0.0" />
26+
<PackageReference Include="coverlet.msbuild" Version="6.0.2">
27+
<IncludeAssets>runtime; build; native; contentfiles; analyzers; buildtransitive</IncludeAssets>
28+
<PrivateAssets>all</PrivateAssets>
29+
</PackageReference>
1930
<PackageReference Include="Microsoft.NET.Test.Sdk" Version="17.8.0" />
2031
<PackageReference Include="MSTest.TestAdapter" Version="3.1.1" />
2132
<PackageReference Include="MSTest.TestFramework" Version="3.1.1" />

algorithm-exercises-csharp/src/UnitTest1.cs renamed to algorithm-exercises-csharp/src/Hello.Test.cs

Lines changed: 5 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -6,13 +6,11 @@ public class UnitTest1
66
[TestMethod]
77
public void TestMethod1()
88
{
9-
}
10-
}
9+
string expected = "Hello World!";
10+
string result = HelloWorld.Hello();
11+
12+
Assert.AreEqual(expected, result);
1113

12-
public class unittest2
13-
{
14-
[TestMethod]
15-
public void TestMethod1()
16-
{
1714
}
1815
}
16+
Lines changed: 14 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,14 @@
1+
namespace algorithm_exercises_csharp;
2+
3+
using System.Diagnostics.CodeAnalysis;
4+
5+
public class HelloWorld
6+
{
7+
[ExcludeFromCodeCoverage]
8+
protected HelloWorld() {}
9+
10+
public static string Hello()
11+
{
12+
return "Hello World!";
13+
}
14+
}

0 commit comments

Comments
 (0)