Skip to content

Commit ee49527

Browse files
author
Gurpreet Singh
committed
additional code coverage
1 parent 65e6f1b commit ee49527

30 files changed

+161
-86
lines changed

.github/workflows/build.yml

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -73,7 +73,8 @@ jobs:
7373
dotnet test
7474
--configuration Release
7575
--collect:"XPlat Code Coverage"
76-
--results-directory ../coverage
76+
--results-directory ../coverage `
77+
--settings ./default.runsettings
7778
7879
- name: Generate coverage report
7980
uses: danielpalme/[email protected]

coverage-by-samples.ps1

Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,11 @@
1+
dotnet test ./src/Samples/TestStack.BDDfy.Samples/TestStack.BDDfy.Samples.csproj `
2+
--collect:"XPlat Code Coverage" `
3+
--results-directory ./TestResults `
4+
--settings ./src/default.runsettings
5+
6+
reportgenerator `
7+
-reports:./TestResults/**/coverage.cobertura.xml `
8+
-targetdir:./CoverageReport `
9+
-reporttypes:Html
10+
11+
Remove-Item -Recurse -Force ./TestResults

coverage-by-tests.ps1

Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,11 @@
1+
dotnet test ./src/TestStack.BDDfy.Tests/TestStack.BDDfy.Tests.csproj `
2+
--collect:"XPlat Code Coverage" `
3+
--results-directory ./TestResults `
4+
--settings ./src/default.runsettings
5+
6+
reportgenerator `
7+
-reports:./TestResults/**/coverage.cobertura.xml `
8+
-targetdir:./CoverageReport `
9+
-reporttypes:Html
10+
11+
Remove-Item -Recurse -Force ./TestResults
Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,7 @@
11
dotnet test ./src `
22
--collect:"XPlat Code Coverage" `
3-
--results-directory ./TestResults
3+
--results-directory ./TestResults `
4+
--settings ./src/default.runsettings
45

56
reportgenerator `
67
-reports:./TestResults/**/coverage.cobertura.xml `
Lines changed: 18 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,18 @@
1+
using System.Threading.Tasks;
2+
using TestStack.BDDfy.Configuration;
3+
using Xunit;
4+
5+
namespace TestStack.BDDfy.Samples
6+
{
7+
public class CanRunAsyncVoidSteps
8+
{
9+
[Fact]
10+
internal void Run() => this.BDDfy();
11+
internal void SetUp() => Configurator.AsyncVoidSupportEnabled = false;
12+
internal void TearDown() => Configurator.AsyncVoidSupportEnabled = true;
13+
14+
internal async void GivenNonAsyncStep() => await Task.CompletedTask;
15+
internal async void WhenSomethingHappens() => await Task.CompletedTask;
16+
internal async void ThenAssertSomething() => await Task.CompletedTask;
17+
}
18+
}

src/TestStack.BDDfy.Tests/Concurrency/TestCollectionName.cs

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2,5 +2,6 @@
22
{
33
internal static class TestCollectionName {
44
public const string ModifiesConfigurator = "ModifiesConfigurator";
5+
public const string Approvals = "Approvals";
56
}
67
}
Lines changed: 26 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,26 @@
1+
using System;
2+
using System.Reflection;
3+
using Shouldly;
4+
using TestStack.BDDfy.Processors;
5+
using Xunit;
6+
7+
namespace TestStack.BDDfy.Tests.Configuration;
8+
9+
public class ExceptionResolverTests
10+
{
11+
[Fact]
12+
public void WhenTargetInvocationException_ResolveRoot_WhenInnerNotAvailable()
13+
{
14+
var ex = new TargetInvocationException(null);
15+
var resolved = ExceptionResolver.Resolve(ex);
16+
resolved.ShouldBeOfType<TargetInvocationException>();
17+
}
18+
19+
[Fact]
20+
public void WhenNotTargetInvocationException_ResolveRoot_EvenWhenInnerIsAvailable()
21+
{
22+
var ex = new System.InvalidCastException("error", new AmbiguousMatchException());
23+
var resolved = ExceptionResolver.Resolve(ex);
24+
resolved.ShouldBeOfType<InvalidCastException>();
25+
}
26+
}

src/TestStack.BDDfy.Tests/HumanizerTests.cs

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -88,5 +88,14 @@ public void ReportsIllegalExampleStepNames(string stepName, string expectedStepT
8888
exception.ShouldNotBeNull();
8989
exception.ShouldBeOfType<ArgumentException>();
9090
}
91+
92+
[Theory]
93+
[InlineData("")]
94+
[InlineData(" ")]
95+
[InlineData(null)]
96+
internal void HumanizeWithNullOrEmptyInput_ReturnsTheSame(string providedInput)
97+
{
98+
Humanizer.Humanize(providedInput).ShouldBe(providedInput);
99+
}
91100
}
92101
}

src/TestStack.BDDfy.Tests/Reporters/Html/ClassicReportBuilderTests.ShouldProduceExpectedHtml.approved.txt

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -159,7 +159,7 @@ body{margin:0;padding:0;padding-bottom:40px;max-width:100%;background-color:#fff
159159
</div>
160160
</div>
161161
<div class='footer'>Powered by <a href='https://github.com/TestStack/TestStack.BDDfy'>BDDfy</a> framework</div>
162-
<script type='text/javascript' src='http://code.jquery.com/jquery-2.1.0.min.js'></script>
162+
<script type='text/javascript' src='https://code.jquery.com/jquery-2.1.0.min.js'></script>
163163
<script>
164164
$(function(){$(".canToggle").each(function(){var n=$("#"+$(this).data("toggle-target"));n.hide();$(this).click(function(){n.toggle(200)})});$(".expandAll").click(function(){$(".steps").css("display","")});$(".collapseAll").click(function(){$(".steps").css("display","none")});$("ul.resultSummary li:not('.storySummary'):not('.scenarioSummary')").append("<input type='checkbox' class='cbx_toggle' checked/>");$(".cbx_toggle").click(function(){var n=$(this),t=n.closest("li").attr("class");$("#testResult div.scenario ."+t).parent().toggle(n.is(":checked"))})});
165165
/*

src/TestStack.BDDfy.Tests/Reporters/Html/ClassicReportBuilderTests.cs

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,12 +1,13 @@
1-
#if Approvals
21
using System;
32
using System.Runtime.CompilerServices;
43
using TestStack.BDDfy.Reporters;
54
using TestStack.BDDfy.Reporters.Html;
5+
using TestStack.BDDfy.Tests.Concurrency;
66
using Xunit;
77

88
namespace TestStack.BDDfy.Tests.Reporters.Html
99
{
10+
[Trait("Category", TestCollectionName.Approvals)]
1011
public class ClassicReportBuilderTests
1112
{
1213
[Fact]
@@ -38,5 +39,4 @@ public void ShouldProduceExpectedHtmlWithExamples()
3839
ReportApprover.Approve(model, sut);
3940
}
4041
}
41-
}
42-
#endif
42+
}

0 commit comments

Comments
 (0)