Skip to content
This repository has been archived by the owner on Jun 13, 2024. It is now read-only.

conditional tests / selective tests - bad title :) #27

Open
davidwallis opened this issue Aug 7, 2017 · 3 comments
Open

conditional tests / selective tests - bad title :) #27

davidwallis opened this issue Aug 7, 2017 · 3 comments
Labels

Comments

@davidwallis
Copy link

I get that having logical comparisons in typical unit tests isn't a good idea,

ie a totally crappy example:

if ($name.StartsWith("blahblahblah")) {
    it "something" {
        $name | should match "blah*"
    }
}
else {
	it "blah" {
		$name | should match "foo*"
	}
}

which I could also do with a single regex ie: blah.|foo. - however this would allow for wrong 'combinations'

but I have specific whole comprehensive tests that I dont want to run in a cloud based test but do in a on prem test and I also have the odd test where I expect different results based on the name of the machine. I also want to use the same set (module) of tests..

Thoughts on how to do this?

  • conditional logical
  • conditional logic by means of a function to do the verification which has its own tests?
  • Name the tests and then only execute tests with a specific naming convention?

Thanks

David

@devblackops
Copy link
Contributor

As far as categorizing sets of tests, you can use Pester's Tag property for that.

So something like:

describe 'my tests' -tag 'onprem' {

}

describe 'my tests' -tag 'cloud' {

}

You could then retrieve only the desired tests with:

$onPremTests = Get-OperationValidation -Tag 'onprem'
$cloudTests = Get-OperationValidation -Tag 'cloud'

I added Pester tag support in PR #16 so you can query for and execute tests based on tags (include or exclude). These changes are not in a published version of OVF unfortunately. You'll have to pull down this repo and manually import the module (the \OperationValidation subfolder). The latest version in source is 1.1.0 and what is published is 1.0.1.

@davidwallis
Copy link
Author

Ahh ok if it supports tags then I will use that version 👍

Any ideas when the gallery is likely to receive these updates as it would make my internal deployment easier as my internal repo pulls from PSGallery and I dont want to manually push to the internal gallery.

Thanks

David

@devblackops
Copy link
Contributor

@JamesWTruher, Can you push version v1.1.0 to the gallery or give me the ability to do so?

Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
Projects
None yet
Development

No branches or pull requests

2 participants