Skip to content

Feedback for datetimes unhelpful #631

@oylenshpeegul

Description

@oylenshpeegul

Datetimes can differ in milliseconds, but Pester doesn't reflect that. If we write

#!/usr/bin/powershell

Describe "Datetime tests" {
    Context "'2016-10-29 08:54:47' is '2016-10-29 08:54:47.001'" {
        [datetime]$dt1 = '2016-10-29 08:54:47'
        [datetime]$dt2 = '2016-10-29 08:54:47.001'
        It "Same?" {
            $dt1 | Should Be $dt2
        }
    }
}

then running it gives

$ ./Datetime.Tests.ps1 
Describing Datetime tests
   Context '2016-10-29 08:54:47' is '2016-10-29 08:54:47.001'
    [-] Same? 1.34s
      Expected: {10/29/2016 08:54:47}
      But was:  {10/29/2016 08:54:47}
      at line: 8 in /home/tim/posh/Datetime.Tests.ps1
      8:            $dt1 | Should Be $dt2

Can we make Pester give more information in the "Expected" and "But was" lines?

Metadata

Metadata

Assignees

Labels

No labels
No labels

Type

No type

Projects

No projects

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions