Skip to content

Commit 3da0dd5

Browse files
committed
Add configuration.Debug.ShowStartMarkers support (fixes pester#2583).
Allow displaying an indication when each test starts: [|] Test name...
1 parent 856f2be commit 3da0dd5

File tree

5 files changed

+40
-2
lines changed

5 files changed

+40
-2
lines changed

Diff for: src/csharp/Pester/DebugConfiguration.cs

+19
Original file line numberDiff line numberDiff line change
@@ -34,6 +34,7 @@ public static DebugConfiguration ShallowClone(DebugConfiguration configuration)
3434
WriteDebugMessages = new BoolOption("Write Debug messages to screen.", false);
3535
WriteDebugMessagesFrom = new StringArrayOption("Write Debug messages from a given source, WriteDebugMessages must be set to true for this to work. You can use like wildcards to get messages from multiple sources, as well as * to get everything.", new string[] { "Discovery", "Skip", "Mock", "CodeCoverage" });
3636
ShowNavigationMarkers = new BoolOption("Write paths after every block and test, for easy navigation in VSCode.", false);
37+
ShowStartMarkers = new BoolOption("Write an indication when each test starts.", false);
3738
ReturnRawResultObject = new BoolOption("Returns unfiltered result object, this is for development only. Do not rely on this object for additional properties, non-public properties will be renamed without previous notice.", false);
3839
}
3940

@@ -45,6 +46,7 @@ public DebugConfiguration(IDictionary configuration) : this()
4546
configuration.AssignValueIfNotNull<bool>(nameof(WriteDebugMessages), v => WriteDebugMessages = v);
4647
configuration.AssignArrayIfNotNull<string>(nameof(WriteDebugMessagesFrom), v => WriteDebugMessagesFrom = v);
4748
configuration.AssignValueIfNotNull<bool>(nameof(ShowNavigationMarkers), v => ShowNavigationMarkers = v);
49+
configuration.AssignValueIfNotNull<bool>(nameof(ShowStartMarkers), v => ShowStartMarkers = v);
4850
configuration.AssignValueIfNotNull<bool>(nameof(ReturnRawResultObject), v => ReturnRawResultObject = v);
4951
}
5052
}
@@ -53,6 +55,7 @@ public DebugConfiguration(IDictionary configuration) : this()
5355
private BoolOption _writeDebugMessages;
5456
private StringArrayOption _writeDebugMessagesFrom;
5557
private BoolOption _showNavigationMarkers;
58+
private BoolOption _showStartMarkers;
5659
private BoolOption _returnRawResultObject;
5760

5861
public BoolOption ShowFullErrors
@@ -119,6 +122,22 @@ public BoolOption ShowNavigationMarkers
119122
}
120123
}
121124

125+
public BoolOption ShowStartMarkers
126+
{
127+
get { return _showStartMarkers; }
128+
set
129+
{
130+
if (_showStartMarkers == null)
131+
{
132+
_showStartMarkers = value;
133+
}
134+
else
135+
{
136+
_showStartMarkers = new BoolOption(_showStartMarkers, value.Value);
137+
}
138+
}
139+
}
140+
122141
public BoolOption ReturnRawResultObject
123142
{
124143
get { return _returnRawResultObject; }

Diff for: src/en-US/about_PesterConfiguration.help.txt

+4
Original file line numberDiff line numberDiff line change
@@ -182,6 +182,10 @@ SECTIONS AND OPTIONS
182182
Type: bool
183183
Default value: $false
184184

185+
ShowStartMarkers: Write an indication when each test starts.
186+
Type: bool
187+
Default value: $false
188+
185189
ReturnRawResultObject: Returns unfiltered result object, this is for development only. Do not rely on this object for additional properties, non-public properties will be renamed without previous notice.
186190
Type: bool
187191
Default value: $false

Diff for: src/functions/Output.ps1

+12-2
Original file line numberDiff line numberDiff line change
@@ -607,10 +607,20 @@ function Get-WriteScreenPlugin ($Verbosity) {
607607
if ($PesterPreference.Output.Verbosity.Value -in 'Detailed', 'Diagnostic') {
608608
$p.EachTestSetupStart = {
609609
param ($Context)
610+
611+
# we are currently in scope of describe so $Test is hardtyped and conflicts
612+
$_test = $Context.Test
613+
610614
# we postponed writing the Describe / Context to grab the Expanded name, because that is done
611615
# during execution to get all the variables in scope, if we are the first test then write it
612-
if ($Context.Test.First) {
613-
Write-BlockToScreen $Context.Test.Block
616+
if ($_test.First) {
617+
Write-BlockToScreen $_test.Block
618+
}
619+
620+
if ($PesterPreference.Debug.ShowStartMarkers.Value) {
621+
$level = $_test.Path.Count
622+
$margin = $ReportStrings.Margin * ($level)
623+
Write-PesterHostMessage -ForegroundColor $ReportTheme.Information "$margin[|] $($_test.ExpandedName)..."
614624
}
615625
}
616626
}

Diff for: test.ps1

+1
Original file line numberDiff line numberDiff line change
@@ -166,6 +166,7 @@ $configuration.Debug.WriteDebugMessagesFrom = 'CodeCoverage'
166166

167167
$configuration.Debug.ShowFullErrors = $false
168168
$configuration.Debug.ShowNavigationMarkers = $false
169+
$configuration.Debug.ShowStartMarkers = $false
169170

170171
if ($null -ne $File -and 0 -lt @($File).Count) {
171172
$configuration.Run.Path = $File

Diff for: tst/Pester.RSpec.Configuration.ts.ps1

+4
Original file line numberDiff line numberDiff line change
@@ -160,6 +160,10 @@ i -PassThru:$PassThru {
160160
[PesterConfiguration]::Default.Debug.ShowNavigationMarkers.Value | Verify-False
161161
}
162162

163+
t "Debug.ShowStartMarkers is `$false" {
164+
[PesterConfiguration]::Default.Debug.ShowStartMarkers.Value | Verify-False
165+
}
166+
163167
t "TestDrive.Enabled is `$true" {
164168
[PesterConfiguration]::Default.TestDrive.Enabled.Value | Verify-True
165169
}

0 commit comments

Comments
 (0)