Implement Pester tests

This commit is contained in:
Maxim Lobanov
2020-07-09 10:53:29 +03:00
parent c6950533af
commit 148b628e0b
19 changed files with 207 additions and 208 deletions
+36
View File
@@ -0,0 +1,36 @@
Describe "Java" {
It "Java <DefaultJavaVersion> is default" -TestCases @(@{ DefaultJavaVersion = 8 }) {
$actualJavaPath = Get-EnvironmentVariable "JAVA_HOME"
$expectedJavaPath = Get-EnvironmentVariable "JAVA_HOME_${DefaultJavaVersion}_X64"
$actualJavaPath | Should -Not -BeNullOrEmpty
$expectedJavaPath | Should -Not -BeNullOrEmpty
$actualJavaPath | Should -Be $expectedJavaPath
}
It "<ToolName>" -TestCases @(
@{ ToolName = "java" }
@{ ToolName = "mvn" }
@{ ToolName = "ant" }
@{ ToolName = "gradle" }
) {
"$ToolName -version" | Should -ReturnZeroExitCode
}
It "Java <Version>" -TestCases @(
@{ Version = "1.7" }
@{ Version = "1.8" }
@{ Version = "11" }
@{ Version = "13" }
) {
$versionNumber = $version.Split(".") | Select-Object -Last 1
$javaVariableValue = Get-EnvironmentVariable "JAVA_HOME_${versionNumber}_X64"
$javaVariableValue | Should -Not -BeNullOrEmpty
$javaPath = Join-Path $javaVariableValue "bin\java"
$result = Get-CommandResult "`"$javaPath`" -version"
$result.ExitCode | Should -Be 0
$result.Output[0] | Should -Match ([regex]::Escape("openjdk version `"${Version}."))
}
}