Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Measure and add steps execution time to outcome. Adjust reports #16

Open
wants to merge 1 commit into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions SpecLight/Infrastructure/ConsoleOutcomePrinter.cs
Original file line number Diff line number Diff line change
Expand Up @@ -46,6 +46,7 @@ public static void PrintOutcomes(Spec spec, Action<string> writeLine)
{
s += ExceptionCaught;
}
s += $"\t({o.ExecutionTime.ToString("s\\.fff")}) sec.";
var cells = new[]
{
message.PadRight(maxMessageWidth),
Expand Down
1 change: 1 addition & 0 deletions SpecLight/Infrastructure/StepOutcome.cs
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,7 @@ public StepOutcome(Step step)

public Step Step { get; private set; }
public Status Status { get; set; }
public TimeSpan ExecutionTime { get; set; }
public Exception Error { get; set; }
public ExceptionDispatchInfo ExceptionDispatchInfo { get; set; }

Expand Down
1 change: 1 addition & 0 deletions SpecLight/Output/SinglePageRazorTemplate.cshtml
Original file line number Diff line number Diff line change
Expand Up @@ -118,6 +118,7 @@
}
@TagBox(o.Step.Tags)
@ExtraData(o.Step.DataDictionary)
<span class="executionTime">(@o.ExecutionTime.ToString("s\\.fff") sec.)</span>
</li>
}
</ul>
Expand Down
14 changes: 12 additions & 2 deletions SpecLight/Output/SinglePageRazorTemplate.generated.cs
Original file line number Diff line number Diff line change
Expand Up @@ -1027,11 +1027,21 @@ function updateHighlight() {

#line default
#line hidden
WriteLiteral("\r\n\t\t\t\t\t\t\t\t</li>\r\n");
WriteLiteral("\r\n <span class=\"executionTime\">(");



#line 122 "..\..\Output\SinglePageRazorTemplate.cshtml"
#line 121 "..\..\Output\SinglePageRazorTemplate.cshtml"
Write(o.ExecutionTime.ToString("s\\.fff"));


#line default
#line hidden
WriteLiteral(" sec.)</span>\r\n\t\t\t\t\t\t\t\t</li>\r\n");



#line 123 "..\..\Output\SinglePageRazorTemplate.cshtml"
}


Expand Down
3 changes: 3 additions & 0 deletions SpecLight/Output/Style.css
Original file line number Diff line number Diff line change
Expand Up @@ -38,6 +38,9 @@ li.pending {
li.notrun {
color: #000000;
}
.executionTime {
color: #8c8c8c;
}
#TableOfContents {
display: block;
position: fixed;
Expand Down
4 changes: 4 additions & 0 deletions SpecLight/Output/Style.less
Original file line number Diff line number Diff line change
Expand Up @@ -86,6 +86,10 @@ li{
}
}

.executionTime {
color: rgba(140, 140, 140, 1);
}


#TableOfContents {
@tcbg: darken(@bg, 6%);
Expand Down
2 changes: 1 addition & 1 deletion SpecLight/Output/Style.min.css

Large diffs are not rendered by default.

7 changes: 5 additions & 2 deletions SpecLight/Spec.cs
Original file line number Diff line number Diff line change
@@ -1,12 +1,11 @@
using System;
using System.Collections.Generic;
using System.Diagnostics;
using System.Dynamic;
using System.Linq;
using System.Reflection;
using System.Runtime.CompilerServices;
using System.Runtime.ExceptionServices;
using System.Text.RegularExpressions;
using System.Threading;
using System.Threading.Tasks;
using SpecLight.Infrastructure;

Expand Down Expand Up @@ -196,9 +195,11 @@ async Task RunOutcomesAsync()
var skip = false;
foreach (var step in Steps)
{
var sw = Stopwatch.StartNew();
step.WillBeSkipped = skip;
Fixtures.ForEach(x => x.StepSetup(step));
var o = await step.ExecuteAsync();
o.ExecutionTime = sw.Elapsed;
Outcomes.Add(o);
skip = skip || o.CausesSkip;
Fixtures.ForEach(x => x.StepTeardown(step));
Expand All @@ -212,9 +213,11 @@ void RunOutcomes()
var skip = false;
foreach (var step in Steps)
{
var sw = Stopwatch.StartNew();
step.WillBeSkipped = skip;
Fixtures.ForEach(x => x.StepSetup(step));
var o = step.Execute();
o.ExecutionTime = sw.Elapsed;
Outcomes.Add(o);
skip = skip || o.CausesSkip;
Fixtures.ForEach(x => x.StepTeardown(step));
Expand Down