File tree Expand file tree Collapse file tree 3 files changed +31
-4
lines changed
Expand file tree Collapse file tree 3 files changed +31
-4
lines changed Original file line number Diff line number Diff line change @@ -11,6 +11,7 @@ public static ContainerInfo Create()
1111 return new ContainerInfo ( ) ;
1212 }
1313
14+ public string Name { get => ToStringConverter . ContainerItemToString ( Type , Item ) ; }
1415 private string _type = Constants . File ;
1516 public string Type
1617 {
Original file line number Diff line number Diff line change @@ -560,10 +560,8 @@ function Get-WriteScreenPlugin ($Verbosity) {
560560 $p.ContainerRunStart = {
561561 param ($Context )
562562
563- if (" file" -eq $Context.Block.BlockContainer.Type ) {
564- # write two spaces to separate each file
565- Write-PesterHostMessage - ForegroundColor $ReportTheme.Container " `n Running tests from '$ ( $Context.Block.BlockContainer.Item ) '"
566- }
563+ # write two spaces to separate each container
564+ Write-PesterHostMessage - ForegroundColor $ReportTheme.Container " `n Running tests from '$ ( $Context.Block.BlockContainer.Name ) '"
567565 }
568566 }
569567
Original file line number Diff line number Diff line change @@ -186,6 +186,34 @@ i -PassThru:$PassThru {
186186 }
187187 }
188188
189+ b ' Output for container names' {
190+ t ' Script Block container names are output' {
191+ $sb = {
192+ $PesterPreference = [PesterConfiguration ]::Default
193+ $PesterPreference.Output.Verbosity = ' Detailed'
194+ $PesterPreference.Output.CIFormat = ' None'
195+ $PesterPreference.Output.RenderMode = ' ConsoleColor'
196+
197+ $container = New-PesterContainer - ScriptBlock {
198+ Describe ' d1' {
199+ It ' i1' {
200+ 1 | Should - Be 1
201+ }
202+ }
203+ }
204+ Invoke-Pester - Container $container
205+ }
206+
207+ $output = Invoke-InNewProcess $sb
208+ # only print the relevant part of output
209+ $null , $run = $output -join " `n " -split ' Running tests.'
210+ $run | Write-Host
211+
212+ $d1Running = $output | Select-String - Pattern ' ^Running tests from.*\<ScriptBlock\>.*$'
213+ @ ($d1Running ).Count | Verify- Equal 1
214+ }
215+ }
216+
189217 b ' Output for data-driven blocks' {
190218 t ' Each block generated from dataset is output' {
191219 # we incorrectly shared reference to the same framework data hashtable
You can’t perform that action at this time.
0 commit comments