Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

TestCases and TestDrive #1645

Closed
Glober777 opened this issue Aug 5, 2020 · 3 comments
Closed

TestCases and TestDrive #1645

Glober777 opened this issue Aug 5, 2020 · 3 comments
Milestone

Comments

@Glober777
Copy link

1. General summary of the issue

With TestCases being evaluated during the discovery phase, it is no longer possible to account for the TestDrive value be available when TestCases value is defined. For that same reason, a variable that's used for TestCases cannot be defined within the BeforeAll block.

2. Describe Your Environment

Pester version     : 5.0.2 C:\Users\seriavio\Documents\PowerShell\Modules\Pester\5.0.2\Pester.psd1
PowerShell version : 7.0.0
OS version         : Microsoft Windows NT 10.0.18363.0

3. Expected Behavior

In 4th version of the Pester module, this was working fine, but in 5th, I'll have update the test code by embedding the value of the TestDrive directly within test itself.

4.Current Behavior

All mentions of TestDrive within the TestCases are replaced with null.

5. Possible Solution

Update the code within the It block to dynamically update the provided TestCases instance value with the actual value of a TestDrive variable

6. Context

I discovered the issue when I was trying to move my tests to Pester 5. In this case, I'll be able to update my code, but I think that this should be added to the list of Breaking Changes maybe?

@hbuckle
Copy link

hbuckle commented Aug 11, 2020

More generally, the scoping of TestCases is a bit of a pain now - I have to duplicate the code in BeforeAll within the Describe block because I use the same setup to create TestCases as I do within the tests themselves. There could do with being a global scope or something where you can do setup that is available in Discovery and Run

@markwragg
Copy link

The example in the documentation for TestDrive:\ also no longer works. It needs to be rewritten to use a BeforeAll block.

@nohwnd
Copy link
Member

nohwnd commented Oct 24, 2020

Added to readme.

@nohwnd nohwnd closed this as completed Oct 24, 2020
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

4 participants