pester / Pester

Pester is the ubiquitous test and mock framework for PowerShell.
https://pester.dev/
Other
3.08k stars 470 forks source link

Tests from Gherkin.Tests.ps1 fail on Linux #937

Closed it-praktyk closed 6 years ago

it-praktyk commented 6 years ago

I enabled executing test from the file Functions\Gherkin.Tests.ps1 (I commented the line) and after that run tests for Gherkin - all tests fail.

PS > Invoke-Pester -Script ./Functions/Gherkin.Tests.ps1
Executing all tests in './Functions/Gherkin.Tests.ps1'

Executing script ./Functions/Gherkin.Tests.ps1

  Describing Invoke-Gherkin
WARNING: OS Information retrieval is not possible, reports will contain only partial
 system data
    [-] Works on the Validator example 3.31s                                               Expected: {13}                                                                       But was:  {0}                                                                        31:         $gherkin.Results.PassedCount | Should -Be $gherkin.Results.TotalCount
      at Invoke-Assertion, <FOLDER_PATH>/Pester/Functions/Assertions/Should.ps1: line 209
      at <ScriptBlock>, <FOLDER_PATH>/Pester/Functions/Gherkin.Tests.ps1: line 31
    [-] Supports testing only scenarios with certain tags 24ms
      Expected: {3}
      But was:  {0}
      35:         $gherkin.Mockery.PassedCount | Should -Be $gherkin.Mockery.TotalCount
      at Invoke-Assertion, <FOLDER_PATH>/Pester/Functions/Assertions/Should.ps1: line 209
      at <ScriptBlock>, <FOLDER_PATH>/Pester/Functions/Gherkin.Tests.ps1: line 35
    [-] Supports tagging examples 32ms
      Expected: {4}
      But was:  {0}
      40:         $gherkin.Example1.PassedCount | Should -Be $gherkin.Example1.TotalCount
      at Invoke-Assertion, <FOLDER_PATH>/Pester/Functions/Assertions/Should.ps1: line 209
      at <ScriptBlock>, <FOLDER_PATH>/Pester/Functions/Gherkin.Tests.ps1: line 40
    [-] Supports excluding scenarios by tag 24ms
      Expected: {10}
      But was:  {0}
      50:         $gherkin.NotMockery.PassedCount | Should -Be 10
      at Invoke-Assertion, <FOLDER_PATH>/Pester/Functions/Assertions/Should.ps1: line 209
      at <ScriptBlock>, <FOLDER_PATH>/Pester/Functions/Gherkin.Tests.ps1: line 50
    [-] Supports running specific scenarios by name 22ms
      Expected: {3}
      But was:  {0}
      56:         $gherkin.NamedScenario.PassedCount | Should -Be 3
      at Invoke-Assertion, <FOLDER_PATH>/Pester/Functions/Assertions/Should.ps1: line 209
      at <ScriptBlock>, <FOLDER_PATH>/Pester/Functions/Gherkin.Tests.ps1: line 56
    [-] Outputs the correct number of passed scenarios 21ms
      Expected: {3}
      But was:  {1}
      61:         @($gherkin.Results.PassedScenarios).Count | Should -Be 3
      at Invoke-Assertion, <FOLDER_PATH>/Pester/Functions/Assertions/Should.ps1: line 209
      at <ScriptBlock>, <FOLDER_PATH>/Pester/Functions/Gherkin.Tests.ps1: line 61

  Describing Gherkin Before Feature
WARNING: OS Information retrieval is not possible, reports will contain only partial
 system data
    [-] Should output two passed scenarios, not the background plus scenarios (bug 911) 2.55s                                                                                   Expected: {2}                                                                        But was:  {1}                                                                  
      82:         @($gherkin.Results.PassedScenarios).Count | Should Be 2
      at Invoke-LegacyAssertion, <FOLDER_PATH>/Pester/Functions/Assertions/Should.ps1: line 190
      at <ScriptBlock>, <FOLDER_PATH>/Pester/Functions/Gherkin.Tests.ps1: line 82

  Describing Gherkin Mocks Feature
WARNING: OS Information retrieval is not possible, reports will contain only partial system data
    [-] Should output three passed scenarios 3.18s                                                                                                                                                                       Expected: {3}                                                                                                                                                                                                      But was:  {1}                                                                                                                                                                                                      104:         @($gherkin.Results.PassedScenarios).Count | Should Be 3                                                                                                                                         
      at Invoke-LegacyAssertion, <FOLDER_PATH>/Pester/Functions/Assertions/Should.ps1: line 190
      at <ScriptBlock>, <FOLDER_PATH>/Pester/Functions/Gherkin.Tests.ps1: line 104
Tests completed in 9.17s
Tests Passed: 0, Failed: 8, Skipped: 0, Pending: 0, Inconclusive: 0
nohwnd commented 6 years ago

@it-praktyk there were some fixes to Gherkin posted this morning, did you try it on sources that had #936 ? Please try again.

it-praktyk commented 6 years ago

Yes, I didn't provide details about the Pester version. My shame.

I performed the test based on the version after merging the pull request #936 to the Pester/master branch - the code base.

nohwnd commented 6 years ago

@Jaykul Do you want to fix this for 4.1, or should I release without Gherkin support on Linux and you fix it in 4.1.1?

nohwnd commented 6 years ago

image Failed count is wrong and it cannot find the implementation for step.

Jaykul commented 6 years ago

I will address this immediately.

Jaykul commented 6 years ago

Bah. Stupid case-sensitive FileSystemProvider.... Short story: -Filter *.steps.ps1 doesn't find files named .Steps.ps1 on Linux.

Jaykul commented 6 years ago

Sorry that took so long. Had some merge weirdness...

nohwnd commented 6 years ago

@Jaykul could you have a look on this today please?

Jaykul commented 6 years ago

I made a couple attempts to resolve this, but there are still weird errors. It seems to be because the test files were changed to use StrictMode in PS2, but I am not sure what's happening.

They pass in PS3+, including on Linux.

If you want to release today with a caveat re. PS2, I can live with that. Otherwise, I'll get back to it in 8 hours or so, after work.

Jaykul commented 6 years ago

After the last set of commits (which I accidentally pushed one at a time), all tests pass on all my systems, from PS2 through PowerShell 5 and 6 Windows 10 Fast Ring and Linux.

I dislike PowerShell 2 more than ever now, but they're working. 😉

nohwnd commented 6 years ago

Fixed by the commit above, forgot to add auto-closing message.