-
Notifications
You must be signed in to change notification settings - Fork 3
/
Copy pathInvoke-TDDworkflow.ps1
46 lines (45 loc) · 1.66 KB
/
Invoke-TDDworkflow.ps1
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
#Requires -Version 4.0 -Modules Pester
# http://mikefrobbins.com/2016/05/12/why-isnt-test-driven-development-more-widely-adopted-and-accepted-by-the-powershell-community/
function Invoke-TDDWorkflow {
[CmdletBinding()]
param (
[ValidateScript({
If (Test-Path -Path $_ -PathType Container) {
$true
}
else {
Throw "'$_' is not a valid directory."
}
})]
[string]$Path = (Get-Location),
[ValidateNotNullOrEmpty()]
[int]$Seconds = 30
)
$Complete = $false
Add-Type -AssemblyName System.Windows.Forms
Clear-Host
while (-not $Complete) {
if ((Invoke-Pester -Script $Path -Quiet -PassThru -OutVariable Results).FailedCount -eq 0) {
if ([System.Windows.Forms.MessageBox]::Show('Is the code complete?', 'Status', 4, 'Question', 'Button2') -eq 'Yes') {
$Complete = $true
}
else {
$Complete = $False
Write-Output "Write a failing unit test for a simple feature that doesn't yet exist."
if ($psISE) {
[System.Windows.Forms.MessageBox]::Show('Click Ok to Continue')
}
else {
Write-Output 'Press any key to continue ...'
$Host.UI.RawUI.ReadKey('NoEcho, IncludeKeyDown') | Out-Null
}
Clear-Host
}
}
else {
Write-Output "Write code until unit test: '$(@($Results.TestResult).Where({$_.Passed -eq $false}, 'First', 1).Name)' passes"
Start-Sleep -Seconds $Seconds
Clear-Host
}
}
}