Skip to content

Commit

Permalink
Comment out flaky timing test
Browse files Browse the repository at this point in the history
  • Loading branch information
nohwnd committed Feb 10, 2019
1 parent c9bdbef commit b63f410
Showing 1 changed file with 33 additions and 32 deletions.
65 changes: 33 additions & 32 deletions Functions/PesterState.Tests.ps1
Original file line number Diff line number Diff line change
Expand Up @@ -119,49 +119,50 @@ InModuleScope Pester {
$result.time.TotalMilliseconds | Should -BeLessOrEqual ($Time.Milliseconds + 10)
}

it "times test groups accurately within 15 milliseconds" {
# TODO: This test is flaky. It often fails because it runs faster than expected
# it "times test groups accurately within 15 milliseconds" {

# Simulating and collecting the time a single 'Describe' test group and single test
$Time = Measure-Command -Expression {
# # Simulating and collecting the time a single 'Describe' test group and single test
# $Time = Measure-Command -Expression {

# Simulating first Describe group
$p.EnterTestGroup('My Describe 2', 'Describe')
# # Simulating first Describe group
# $p.EnterTestGroup('My Describe 2', 'Describe')

# Sleeping to simulate setup time, like a beforeAll block
Start-Sleep -Milliseconds 100
# # Sleeping to simulate setup time, like a beforeAll block
# Start-Sleep -Milliseconds 100

# Simulating the start of a test
$p.EnterTest()
# # Simulating the start of a test
# $p.EnterTest()

# Sleeping to simulate test time
Start-Sleep -Milliseconds 100
# # Sleeping to simulate test time
# Start-Sleep -Milliseconds 100

# Simulating the end of a test
$p.LeaveTest()
# # Simulating the end of a test
# $p.LeaveTest()

<#
Invoking the add test result with the typical value of $null for ticks which should mean that
the time of the test is automatically recorded as the time between the start of the test
and the finish of the test which should also match the time we recorded using the
Measure-Command
#>
$p.AddTestResult("result", "Passed", $null)
# <#
# Invoking the add test result with the typical value of $null for ticks which should mean that
# the time of the test is automatically recorded as the time between the start of the test
# and the finish of the test which should also match the time we recorded using the
# Measure-Command
# #>
# $p.AddTestResult("result", "Passed", $null)

# Sleeping to simulate teardown time
Start-Sleep -Milliseconds 100
# # Sleeping to simulate teardown time
# Start-Sleep -Milliseconds 100

# Simulating the finish of our 'Describe' test group
$p.LeaveTestGroup('My Describe 2', 'Describe')
}
# # Simulating the finish of our 'Describe' test group
# $p.LeaveTestGroup('My Describe 2', 'Describe')
# }

# Getting the last test group result
$result = $p.TestGroupStack.peek().Actions.ToArray()[-1]
# # Getting the last test group result
# $result = $p.TestGroupStack.peek().Actions.ToArray()[-1]

# The time recorded as taken during the test should be within + or - 15 milliseconds of the time we
# recorded using Measure-Command
$result.time.TotalMilliseconds | Should -BeGreaterOrEqual ($Time.Milliseconds - 15)
$result.time.TotalMilliseconds | Should -BeLessOrEqual ($Time.Milliseconds + 15)
}
# # The time recorded as taken during the test should be within + or - 15 milliseconds of the time we
# # recorded using Measure-Command
# $result.time.TotalMilliseconds | Should -BeGreaterOrEqual ($Time.Milliseconds - 15)
# $result.time.TotalMilliseconds | Should -BeLessOrEqual ($Time.Milliseconds + 15)
# }

it "accurately increments total testsuite time within 10 milliseconds" {
# Initial time for the current testsuite
Expand Down

0 comments on commit b63f410

Please sign in to comment.