├── .gitignore ├── .vscode ├── launch.json ├── settings.json └── tasks.json ├── ATDD.TestScriptor.csproj ├── Classes ├── Cleanup.cs ├── Given.cs ├── TestFeature.cs ├── TestScenario.cs ├── TestScenarioElement.cs ├── TestScenarios.cs ├── Then.cs └── When.cs ├── Cmdlets ├── ConvertToALTestCodeunitCmdlet.cs ├── NewATDDCleanupCmdlet.cs ├── NewATDDGivenCmdlet.cs ├── NewATDDTestFeatureCmdlet.cs ├── NewATDDTestScenarioCmdlet.cs ├── NewATDDThenCmdlet.cs └── NewATDDWhenCmdlet.cs ├── Helpers └── ExtensionMethods.cs ├── LICENSE ├── README.md ├── assets └── Cod81000.LookupValueUTCustomer.al ├── demo ├── ATDD.TestScriptor_Demo.gif └── demo.ps1 ├── docs ├── ConvertTo-ALTestCodeunit.md ├── New-ATDDCleanup.md ├── New-ATDDGiven.md ├── New-ATDDTestFeature.md ├── New-ATDDTestScenario.md ├── New-ATDDThen.md ├── New-ATDDWhen.md └── about_ATDD.TestScriptor.md ├── format.ps1xml └── manifest.psd1 /.gitignore: -------------------------------------------------------------------------------- 1 | /bin 2 | /obj 3 | /output -------------------------------------------------------------------------------- /.vscode/launch.json: -------------------------------------------------------------------------------- 1 | { 2 | // Use IntelliSense to learn about possible attributes. 3 | // Hover to view descriptions of existing attributes. 4 | // For more information, visit: https://go.microsoft.com/fwlink/?linkid=830387 5 | "version": "0.2.0", 6 | "configurations": [ 7 | { 8 | "name": ".NET Core Launch (console)", 9 | "type": "coreclr", 10 | "request": "launch", 11 | "WARNING01": "*********************************************************************************", 12 | "WARNING02": "The C# extension was unable to automatically to decode projects in the current", 13 | "WARNING03": "workspace to create a runnable lanch.json file. A template launch.json file has", 14 | "WARNING04": "been created as a placeholder.", 15 | "WARNING05": "", 16 | "WARNING06": "If OmniSharp is currently unable to load your project, you can attempt to resolve", 17 | "WARNING07": "this by restoring any missing project dependencies (example: run 'dotnet restore')", 18 | "WARNING08": "and by fixing any reported errors from building the projects in your workspace.", 19 | "WARNING09": "If this allows OmniSharp to now load your project then --", 20 | "WARNING10": " * Delete this file", 21 | "WARNING11": " * Open the Visual Studio Code command palette (View->Command Palette)", 22 | "WARNING12": " * run the command: '.NET: Generate Assets for Build and Debug'.", 23 | "WARNING13": "", 24 | "WARNING14": "If your project requires a more complex launch configuration, you may wish to delete", 25 | "WARNING15": "this configuration and pick a different template using the 'Add Configuration...'", 26 | "WARNING16": "button at the bottom of this file.", 27 | "WARNING17": "*********************************************************************************", 28 | "preLaunchTask": "build", 29 | "program": "${workspaceFolder}/bin/Debug//.dll", 30 | "args": [], 31 | "cwd": "${workspaceFolder}", 32 | "console": "internalConsole", 33 | "stopAtEntry": false 34 | }, 35 | { 36 | "name": ".NET Core Attach", 37 | "type": "coreclr", 38 | "request": "attach", 39 | "processId": "${command:pickProcess}" 40 | } 41 | ] 42 | } -------------------------------------------------------------------------------- /.vscode/settings.json: -------------------------------------------------------------------------------- 1 | { 2 | "editor.formatOnSave": true 3 | } -------------------------------------------------------------------------------- /.vscode/tasks.json: -------------------------------------------------------------------------------- 1 | { 2 | // See https://go.microsoft.com/fwlink/?LinkId=733558 3 | // for the documentation about the tasks.json format 4 | "version": "2.0.0", 5 | "tasks": [ 6 | { 7 | "label": "build", 8 | "command": "dotnet build", 9 | "type": "shell", 10 | "group": { 11 | "kind": "build", 12 | "isDefault": true 13 | }, 14 | "presentation": { 15 | "reveal": "always", 16 | "clear": true 17 | }, 18 | "problemMatcher": "$msCompile" 19 | }, 20 | { 21 | "label": "help", 22 | "command": "pwsh", 23 | "args": [ 24 | "-Command", 25 | "New-ExternalHelp -Path ./docs/ -OutputPath ./output/ATDD.TestScriptor/en-us -ShowProgress -Force" 26 | ], 27 | "type": "shell", 28 | "problemMatcher": [] 29 | }, 30 | { 31 | "label": "test", 32 | "command": "pwsh", 33 | "type": "shell", 34 | "args": [ 35 | "-File", 36 | "./demo.ps1" 37 | ], 38 | "group": { 39 | "kind": "test", 40 | "isDefault": true 41 | }, 42 | "presentation": { 43 | "reveal": "always", 44 | "clear": true 45 | } 46 | } 47 | ] 48 | } -------------------------------------------------------------------------------- /ATDD.TestScriptor.csproj: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | netstandard2.0 5 | output/$(AssemblyName)/ 6 | false 7 | 8 | 9 | 10 | 11 | 12 | 13 | 14 | 15 | 16 | 17 | 18 | -------------------------------------------------------------------------------- /Classes/Cleanup.cs: -------------------------------------------------------------------------------- 1 | namespace ATDD.TestScriptor 2 | { 3 | public class Cleanup : TestScenarioElement 4 | { 5 | public Cleanup(string target) => Target = target; 6 | 7 | public string Target { get; } 8 | 9 | public override string ToString() => $"[CLEANUP] {Target}"; 10 | 11 | public override string Value => Target; 12 | } 13 | } -------------------------------------------------------------------------------- /Classes/Given.cs: -------------------------------------------------------------------------------- 1 | namespace ATDD.TestScriptor 2 | { 3 | public class Given : TestScenarioElement 4 | { 5 | public Given(string situation) => Situation = situation; 6 | public string Situation { get; } 7 | 8 | public override string ToString() => $"[GIVEN] {Situation}"; 9 | 10 | public override string Value => Situation; 11 | } 12 | } -------------------------------------------------------------------------------- /Classes/TestFeature.cs: -------------------------------------------------------------------------------- 1 | using System; 2 | using System.Collections.ObjectModel; 3 | 4 | namespace ATDD.TestScriptor 5 | { 6 | public class TestFeature 7 | { 8 | public TestFeature(string name, params TestScenario[] scenarios) 9 | { 10 | Name = name; 11 | Scenarios = new TestScenarios(this); 12 | 13 | Scenarios.AddRange(scenarios); 14 | } 15 | 16 | public string Name { get; } 17 | public TestScenarios Scenarios { get; } 18 | 19 | public override string ToString() => $"[FEATURE] {Name}"; 20 | } 21 | } 22 | -------------------------------------------------------------------------------- /Classes/TestScenario.cs: -------------------------------------------------------------------------------- 1 | using System.Collections.ObjectModel; 2 | 3 | namespace ATDD.TestScriptor 4 | { 5 | public class TestScenario 6 | { 7 | public TestScenario(int id, string name, params TestScenarioElement[] elements) 8 | { 9 | ID = id; 10 | Name = name; 11 | Elements.AddRange(elements); 12 | } 13 | public int ID { get; set; } 14 | public string Name { get; set; } 15 | 16 | public TestFeature Feature { get; internal set; } 17 | public Collection Elements { get; } = new Collection(); 18 | 19 | public override string ToString() => $"[SCENARIO #{ID:0000}] {Name}"; 20 | } 21 | } -------------------------------------------------------------------------------- /Classes/TestScenarioElement.cs: -------------------------------------------------------------------------------- 1 | namespace ATDD.TestScriptor 2 | { 3 | public abstract class TestScenarioElement 4 | { 5 | public abstract string Value { get; } 6 | } 7 | } -------------------------------------------------------------------------------- /Classes/TestScenarios.cs: -------------------------------------------------------------------------------- 1 | using System.Collections.ObjectModel; 2 | 3 | namespace ATDD.TestScriptor 4 | { 5 | public class TestScenarios : Collection 6 | { 7 | public TestScenarios(TestFeature feature) => Feature = feature; 8 | 9 | public TestFeature Feature { get; } 10 | 11 | protected override void InsertItem(int index, TestScenario item) 12 | { 13 | item.Feature = Feature; 14 | base.InsertItem(index, item); 15 | } 16 | 17 | protected override void RemoveItem(int index) 18 | { 19 | this[index].Feature = null; 20 | base.RemoveItem(index); 21 | } 22 | } 23 | } -------------------------------------------------------------------------------- /Classes/Then.cs: -------------------------------------------------------------------------------- 1 | namespace ATDD.TestScriptor 2 | { 3 | public class Then : TestScenarioElement 4 | { 5 | public Then(string expectedResult) => ExpectedResult = expectedResult; 6 | public string ExpectedResult { get; } 7 | 8 | public override string ToString() => $"[THEN] {ExpectedResult}"; 9 | 10 | public override string Value => ExpectedResult; 11 | } 12 | } 13 | -------------------------------------------------------------------------------- /Classes/When.cs: -------------------------------------------------------------------------------- 1 | namespace ATDD.TestScriptor 2 | { 3 | public class When : TestScenarioElement 4 | { 5 | public When(string condition) => Condition = condition; 6 | public string Condition { get; } 7 | 8 | public override string ToString() => $"[WHEN] {Condition}"; 9 | 10 | public override string Value => Condition; 11 | } 12 | } -------------------------------------------------------------------------------- /Cmdlets/ConvertToALTestCodeunitCmdlet.cs: -------------------------------------------------------------------------------- 1 | using System; 2 | using System.CodeDom.Compiler; 3 | using System.Collections.Generic; 4 | using System.Globalization; 5 | using System.IO; 6 | using System.Linq; 7 | using System.Management.Automation; 8 | using System.Text.RegularExpressions; 9 | 10 | namespace ATDD.TestScriptor 11 | { 12 | [Cmdlet(VerbsData.ConvertTo, "ALTestCodeunit")] 13 | public class ConvertToALTestCodeunitCmdlet : Cmdlet 14 | { 15 | private List scenarioCache = new List(); 16 | 17 | [Parameter(Mandatory = true, Position = 0)] 18 | public int CodeunitID { get; set; } 19 | 20 | [Parameter(Mandatory = true, Position = 1)] 21 | public string CodeunitName { get; set; } 22 | 23 | [Parameter()] 24 | public SwitchParameter InitializeFunction { get; set; } 25 | 26 | [Parameter(ValueFromPipeline = true)] 27 | [ValidateNotNull()] 28 | public TestFeature[] Feature { get; set; } = new TestFeature[] { }; 29 | 30 | [Parameter()] 31 | [ValidateNotNullOrEmpty()] 32 | public string GivenFunctionName { get; set; } = "{0}"; 33 | 34 | [Parameter()] 35 | [ValidateNotNullOrEmpty()] 36 | public string WhenFunctionName { get; set; } = "{0}"; 37 | 38 | [Parameter()] 39 | [ValidateNotNullOrEmpty()] 40 | public string ThenFunctionName { get; set; } = "{0}"; 41 | 42 | [Parameter()] 43 | public SwitchParameter DoNotAddErrorToHelperFunctions { get; set; } 44 | 45 | [Parameter()] 46 | [ValidateNotNull()] 47 | public string BannerFormat { get; set; } = "// Generated on {0} at {1} by {2}"; 48 | 49 | protected override void ProcessRecord() => scenarioCache.AddRange(Feature.SelectMany(f => f.Scenarios)); 50 | 51 | protected override void EndProcessing() 52 | { 53 | var uniqueFeatureNames = 54 | scenarioCache 55 | .Select(s => s.Feature.ToString()) 56 | .Distinct(); 57 | 58 | var elementFunctionNames = 59 | scenarioCache 60 | .SelectMany(s => s.Elements) 61 | .Select(e => new { Element = e, FunctionName = GetElementFunctionName(e) }) 62 | .ToDictionary(o => o.Element, o => o.FunctionName); 63 | 64 | var uniqueFunctionNames = 65 | elementFunctionNames 66 | .Values 67 | .Distinct() 68 | .OrderBy(f => f); 69 | 70 | WarnIfPlaceHolderMissing(GivenFunctionName); 71 | WarnIfPlaceHolderMissing(WhenFunctionName); 72 | WarnIfPlaceHolderMissing(ThenFunctionName); 73 | 74 | using (var stringWriter = new StringWriter()) 75 | { 76 | using (var writer = new IndentedTextWriter(stringWriter)) 77 | { 78 | writer.WriteLine($"codeunit {CodeunitID} \"{CodeunitName}\""); 79 | writer.WriteLine("{"); 80 | writer.Indent++; 81 | WriteBanner(writer); 82 | writer.WriteLine("Access = Public;"); 83 | writer.WriteLine("InherentEntitlements = X;"); 84 | writer.WriteLine("InherentPermissions = X;"); 85 | writer.WriteLine("Subtype = Test;"); 86 | writer.WriteLine(); 87 | writer.WriteLine("trigger OnRun()"); 88 | writer.WriteLine("begin"); 89 | writer.Indent++; 90 | writer.WriteLines(uniqueFeatureNames.Select(f => $"// {f}")); 91 | writer.Indent--; 92 | writer.WriteLine("end;"); 93 | writer.WriteLine(); 94 | scenarioCache.ForEach(s => WriteALTestFunction(s, elementFunctionNames, writer)); 95 | WriteInitializeFunction(writer); 96 | uniqueFunctionNames.ForEach(f => WriteDummyFunction(f, writer)); 97 | writer.Indent--; 98 | writer.WriteLine("}"); 99 | } 100 | 101 | WriteObject(stringWriter.ToString()); 102 | } 103 | } 104 | 105 | protected void WriteALTestFunction(TestScenario scenario, Dictionary elementFunctionNames, IndentedTextWriter writer) 106 | { 107 | writer.WriteLine("[Test]"); 108 | writer.WriteLine($"procedure {SanitizeName(scenario.Name)}()"); 109 | writer.WriteLine($"// {scenario.Feature.ToString()}"); 110 | writer.WriteLine("begin"); 111 | writer.Indent++; 112 | writer.WriteLine($"// {scenario.ToString()}"); 113 | writer.WriteLineIf(InitializeFunction, "Initialize();"); 114 | writer.WriteLine(); 115 | writer.WriteLines(scenario.Elements.OfType().SelectMany(g => ElementLines(g, elementFunctionNames))); 116 | writer.WriteLines(scenario.Elements.OfType().SelectMany(w => ElementLines(w, elementFunctionNames))); 117 | writer.WriteLines(scenario.Elements.OfType().SelectMany(t => ElementLines(t, elementFunctionNames))); 118 | writer.WriteLines(scenario.Elements.OfType().SelectMany(c => ElementLines(c, elementFunctionNames))); 119 | writer.Indent--; 120 | writer.WriteLine("end;"); 121 | writer.WriteLine(); 122 | } 123 | 124 | protected IEnumerable ElementLines(TestScenarioElement element, Dictionary elementFunctionNames) 125 | { 126 | yield return $"// {element.ToString()}"; 127 | yield return $"{elementFunctionNames[element]}();"; 128 | yield return ""; 129 | } 130 | 131 | protected void WriteBanner(IndentedTextWriter writer) 132 | { 133 | var now = DateTime.Now; 134 | var banner = 135 | string.Format( 136 | BannerFormat, 137 | now.ToShortDateString(), 138 | now.ToShortTimeString(), 139 | Environment.UserName); 140 | 141 | if (!string.IsNullOrEmpty(banner)) 142 | { 143 | writer.WriteLine(banner); 144 | writer.WriteLine(); 145 | } 146 | } 147 | 148 | protected void WriteInitializeFunction(IndentedTextWriter writer) 149 | { 150 | if (InitializeFunction) 151 | { 152 | writer.WriteLine("var"); 153 | writer.Indent++; 154 | writer.WriteLine("IsInitialized: Boolean;"); 155 | writer.Indent--; 156 | writer.WriteLine(); 157 | 158 | writer.WriteLine("local procedure Initialize()"); 159 | writer.WriteLine("var"); 160 | writer.Indent++; 161 | writer.WriteLine("LibraryTestInitialize: Codeunit \"Library - Test Initialize\";"); 162 | writer.Indent--; 163 | writer.WriteLine("begin"); 164 | writer.Indent++; 165 | writer.WriteLine($"LibraryTestInitialize.OnTestInitialize(Codeunit::\"{CodeunitName}\");"); 166 | writer.WriteLine(); 167 | writer.WriteLine("if IsInitialized then"); 168 | writer.Indent++; 169 | writer.WriteLine("exit;"); 170 | writer.Indent--; 171 | writer.WriteLine(); 172 | writer.WriteLine($"LibraryTestInitialize.OnBeforeTestSuiteInitialize(Codeunit::\"{CodeunitName}\");"); 173 | writer.WriteLine(); 174 | writer.WriteLine("IsInitialized := true;"); 175 | writer.WriteLine("Commit();"); 176 | writer.WriteLine(); 177 | writer.WriteLine($"LibraryTestInitialize.OnAfterTestSuiteInitialize(Codeunit::\"{CodeunitName}\");"); 178 | writer.Indent--; 179 | writer.WriteLine("end;"); 180 | writer.WriteLine(); 181 | } 182 | } 183 | 184 | protected void WriteDummyFunction(string name, IndentedTextWriter writer) 185 | { 186 | writer.WriteLine($"local procedure {name}()"); 187 | writer.WriteLine("begin"); 188 | if (!DoNotAddErrorToHelperFunctions) 189 | { 190 | writer.Indent++; 191 | writer.WriteLine($"Error('{name} not implemented.')"); 192 | writer.Indent--; 193 | } 194 | writer.WriteLine("end;"); 195 | writer.WriteLine(); 196 | } 197 | 198 | protected string GetElementFunctionName(TestScenarioElement element) 199 | { 200 | switch (element) 201 | { 202 | case Given given: return FormatElement(element, GivenFunctionName); 203 | case When @when: return FormatElement(element, WhenFunctionName); 204 | case Then then: return FormatElement(element, ThenFunctionName); 205 | default: return SanitizeName(element.Value); 206 | } 207 | } 208 | 209 | protected string FormatElement(TestScenarioElement element, string format) 210 | { 211 | try 212 | { 213 | return SanitizeName(string.Format(format, element.Value)); 214 | } 215 | catch (FormatException e) 216 | { 217 | throw new FormatException($"Function name format '{format}' should not contain placeholders other than '{{0}}'", e); 218 | } 219 | } 220 | 221 | protected void WarnIfPlaceHolderMissing(string format) 222 | { 223 | if (!format.Contains("{0}")) 224 | WriteWarning($"Function name format '{format}' does not contain placeholder '{{0}}'"); 225 | } 226 | 227 | protected static string SanitizeName(string name) => 228 | Regex 229 | .Split(name, @"\W", RegexOptions.CultureInvariant) 230 | .Where(s => !string.IsNullOrEmpty(s)) 231 | .Select(s => Regex.Replace(s, "^.", m => m.Value.ToUpperInvariant())) 232 | .Join(""); 233 | } 234 | } -------------------------------------------------------------------------------- /Cmdlets/NewATDDCleanupCmdlet.cs: -------------------------------------------------------------------------------- 1 | using System.Management.Automation; 2 | 3 | namespace ATDD.TestScriptor 4 | { 5 | [Cmdlet(VerbsCommon.New, "ATDDCleanup")] 6 | [Alias("Cleanup")] 7 | public class NewATDDCleanupCmdlet : Cmdlet 8 | { 9 | [Parameter(Mandatory = true, Position = 0)] 10 | public string Target { get; set; } 11 | 12 | protected override void EndProcessing() 13 | { 14 | WriteObject( 15 | new Cleanup(Target) 16 | ); 17 | } 18 | } 19 | } -------------------------------------------------------------------------------- /Cmdlets/NewATDDGivenCmdlet.cs: -------------------------------------------------------------------------------- 1 | using System.Management.Automation; 2 | 3 | namespace ATDD.TestScriptor 4 | { 5 | [Cmdlet(VerbsCommon.New, "ATDDGiven")] 6 | [Alias("Given")] 7 | public class NewATDDGivenCmdlet : Cmdlet 8 | { 9 | [Parameter(Mandatory = true, Position = 0)] 10 | public string Situation { get; set; } 11 | 12 | protected override void EndProcessing() 13 | { 14 | WriteObject( 15 | new Given(Situation) 16 | ); 17 | } 18 | } 19 | } -------------------------------------------------------------------------------- /Cmdlets/NewATDDTestFeatureCmdlet.cs: -------------------------------------------------------------------------------- 1 | using System.Linq; 2 | using System.Management.Automation; 3 | 4 | namespace ATDD.TestScriptor 5 | { 6 | [Cmdlet(VerbsCommon.New, "ATDDTestFeature")] 7 | [Alias("Feature")] 8 | public class NewATDDTestFeatureCmdlet : Cmdlet 9 | { 10 | [Parameter(Mandatory = true, Position = 0)] 11 | public string Name { get; set; } 12 | 13 | [Parameter(Position = 1)] 14 | [ValidateNotNull()] 15 | public ScriptBlock Scenarios { get; set; } = ScriptBlock.Create(""); 16 | 17 | protected override void EndProcessing() 18 | { 19 | WriteObject( 20 | new TestFeature( 21 | Name, 22 | Scenarios.Invoke().Select(o => o.BaseObject).Cast().ToArray() 23 | ) 24 | ); 25 | } 26 | } 27 | } 28 | -------------------------------------------------------------------------------- /Cmdlets/NewATDDTestScenarioCmdlet.cs: -------------------------------------------------------------------------------- 1 | using System.Linq; 2 | using System.Management.Automation; 3 | 4 | namespace ATDD.TestScriptor 5 | { 6 | [Cmdlet(VerbsCommon.New, "ATDDTestScenario")] 7 | [Alias("Scenario")] 8 | public class NewATDDTestScenarioCmdlet : Cmdlet 9 | { 10 | [Parameter(Mandatory = true, Position = 0)] 11 | public int ID { get; set; } 12 | 13 | [Parameter(Mandatory = true, Position = 1)] 14 | public string Name { get; set; } 15 | 16 | [Parameter(Position = 2)] 17 | [ValidateNotNull()] 18 | public ScriptBlock Elements { get; set; } = ScriptBlock.Create(""); 19 | 20 | protected override void EndProcessing() 21 | { 22 | var elements = Elements.Invoke().Select(o => o.BaseObject).Cast(); 23 | 24 | if (!elements.OfType().Any()) 25 | WriteWarning($"Scenario {ID} {Name} does not contain any elements of type Given."); 26 | if (!elements.OfType().Any()) 27 | WriteWarning($"Scenario {ID} {Name} does not contain any elements of type When."); 28 | if (!elements.OfType().Any()) 29 | WriteWarning($"Scenario {ID} {Name} does not contain any elements of type Then."); 30 | 31 | WriteObject( 32 | new TestScenario( 33 | ID, 34 | Name, 35 | elements.ToArray()) 36 | ); 37 | } 38 | } 39 | } -------------------------------------------------------------------------------- /Cmdlets/NewATDDThenCmdlet.cs: -------------------------------------------------------------------------------- 1 | using System.Management.Automation; 2 | 3 | namespace ATDD.TestScriptor 4 | { 5 | [Cmdlet(VerbsCommon.New, "ATDDThen")] 6 | [Alias("Then")] 7 | public class NewATDDThenCmdlet : Cmdlet 8 | { 9 | [Parameter(Mandatory = true, Position = 0)] 10 | public string ExpectedResult { get; set; } 11 | 12 | protected override void EndProcessing() 13 | { 14 | WriteObject( 15 | new Then(ExpectedResult) 16 | ); 17 | } 18 | } 19 | } -------------------------------------------------------------------------------- /Cmdlets/NewATDDWhenCmdlet.cs: -------------------------------------------------------------------------------- 1 | using System.Management.Automation; 2 | 3 | namespace ATDD.TestScriptor 4 | { 5 | [Cmdlet(VerbsCommon.New, "ATDDWhen")] 6 | [Alias("When")] 7 | public class NewATDDWhenCmdlet : Cmdlet 8 | { 9 | [Parameter(Mandatory = true, Position = 0)] 10 | public string Condition { get; set; } 11 | 12 | protected override void EndProcessing() 13 | { 14 | WriteObject( 15 | new When(Condition) 16 | ); 17 | } 18 | } 19 | } -------------------------------------------------------------------------------- /Helpers/ExtensionMethods.cs: -------------------------------------------------------------------------------- 1 | using System; 2 | using System.CodeDom.Compiler; 3 | using System.Collections.Generic; 4 | using System.Collections.ObjectModel; 5 | 6 | namespace ATDD.TestScriptor 7 | { 8 | public static class ExtensionMethods 9 | { 10 | public static void AddRange(this Collection collection, IEnumerable items) => 11 | items.ForEach(i => collection.Add(i)); 12 | 13 | public static IEnumerable ForEach(this IEnumerable items, Action action) 14 | { 15 | foreach (var item in items) 16 | { 17 | action(item); 18 | } 19 | 20 | return items; 21 | } 22 | 23 | public static string Join(this IEnumerable items, string separator) => 24 | string.Join(separator, items); 25 | 26 | public static void WriteLineIf(this IndentedTextWriter writer, bool condition, string line) 27 | { 28 | if (condition) 29 | writer.WriteLine(line); 30 | } 31 | 32 | public static void WriteLines(this IndentedTextWriter writer, IEnumerable lines) => 33 | lines.ForEach(l => writer.WriteLine(l)); 34 | } 35 | } -------------------------------------------------------------------------------- /LICENSE: -------------------------------------------------------------------------------- 1 | MIT License 2 | 3 | Copyright (c) 2019 fluxxus.nl 4 | 5 | Permission is hereby granted, free of charge, to any person obtaining a copy 6 | of this software and associated documentation files (the "Software"), to deal 7 | in the Software without restriction, including without limitation the rights 8 | to use, copy, modify, merge, publish, distribute, sublicense, and/or sell 9 | copies of the Software, and to permit persons to whom the Software is 10 | furnished to do so, subject to the following conditions: 11 | 12 | The above copyright notice and this permission notice shall be included in all 13 | copies or substantial portions of the Software. 14 | 15 | THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR 16 | IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, 17 | FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE 18 | AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER 19 | LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, 20 | OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE 21 | SOFTWARE. 22 | -------------------------------------------------------------------------------- /README.md: -------------------------------------------------------------------------------- 1 | ### Note 2 | This PowerShell module is not really maintained as we are working on a VSCode extension with the same name. You can find its itHub project [here](https://github.com/fluxxus-nl/ATDD.TestScriptor.VSCodeExtension). However, if the PowerShell module still makes sense to you - and thanx for using it - let know us by creating an issue with your business case in it. 3 | 4 | # ATDD.TestScriptor 5 | 6 | The Acceptance Test-Driven Development test scriptor allows the user to define in a managed matter ATDD test scenarios and convert it into a code structure to facilitate fast test code development. At this moment this conversion is only implemented for .al. 7 | 8 | The ATDD pattern is defined by so called tags: 9 | 10 | * FEATURE: defines what feature(s) the test or collection of test cases is testing 11 | * SCENARIO: defines for a single test the scenario being teste 12 | * GIVEN: defines what data setup is needed; a test case can have multiple GIVEN tags when data setup is more complex 13 | * WHEN: defines the action under test; each test case should have only one WHEN tag 14 | * THEN: defines the result of the action, or more specifically the verification of the result; if multiple results apply, multiple THEN tags will be needed 15 | 16 | ## Installation instructions 17 | Type either of the following in a PowerShell prompt: 18 | 19 | - to install for all users; requires prompt with admin privileges: 20 | ```powershell 21 | Install-Module ATDD.TestScriptor 22 | ``` 23 | - to install for current user only; no admin privileges required: 24 | ```powershell 25 | Install-Module ATDD.TestScriptor -Scope CurrentUser 26 | ``` 27 | 28 | Note that you may be asked for confirmation if you haven't previously marked the PowerShell Gallery repository as a trusted PowerShell module source. 29 | 30 | ## Build/usage instructions (beta phase) 31 | 32 | - Clone this repository to a folder on your machine; 33 | - Only on Windows: open the .csproj file and replace the `cp` command with `copy` in the `` elements; 34 | - Open a PowerShell prompt and navigate to your local repository folder; 35 | - Type `dotnet build` and press Enter; 36 | - Type `./demo.ps1` to view sample output. 37 | 38 | ## Demo 39 | 40 | ![ATDD.TestScriptor Demo](demo/ATDD.TestScriptor_Demo.gif) 41 | 42 | Need a more comprehensive demo? Have a look at this Areopa webinar were this module was used: https://www.youtube.com/watch?v=ma48oWYWCvw&t=82s 43 | -------------------------------------------------------------------------------- /assets/Cod81000.LookupValueUTCustomer.al: -------------------------------------------------------------------------------- 1 | codeunit 81000 "LookupValue UT Customer" 2 | { 3 | Subtype = Test; 4 | 5 | var 6 | Assert: Codeunit Assert; 7 | LibrarySales: Codeunit "Library - Sales"; 8 | LibraryTestInitialize: Codeunit "Library - Test Initialize"; 9 | LibraryLookupValue: Codeunit "Library - Lookup Value"; 10 | LibraryMessages: Codeunit "Library - Messages"; 11 | isInitialized: Boolean; 12 | 13 | //[FEATURE] LookupValue UT Customer 14 | 15 | //Instruction NOTES 16 | //(1) Replacing the argument LookupValueCode in verification call, i.e. [THEN] clause, should make any test fail 17 | //(2) Making field "Lookup Value Code", on any of the related pages, Visible=false should make any UI test fail 18 | 19 | [Test] 20 | procedure AssignLookupValueToCustomer() 21 | //[FEATURE] LookupValue UT Customer 22 | var 23 | Customer: Record Customer; 24 | LookupValueCode: Code[10]; 25 | begin 26 | //[SCENARIO #0001] Assign lookup value to customer 27 | Initialize(); 28 | 29 | //[GIVEN] A lookup value 30 | LookupValueCode := CreateLookupValueCode(); 31 | //[GIVEN] A customer 32 | CreateCustomer(Customer); 33 | 34 | //[WHEN] Set lookup value on customer 35 | SetLookupValueOnCustomer(Customer, LookupValueCode, DoModify()); 36 | 37 | //[THEN] Customer has lookup value field populated 38 | VerifyLookupValueOnCustomer(Customer."No.", LookupValueCode); 39 | end; 40 | 41 | [Test] 42 | procedure AssignNonExistingLookupValueToCustomer() 43 | //[FEATURE] LookupValue UT Customer 44 | var 45 | Customer: Record Customer; 46 | LookupValueCode: Code[10]; 47 | begin 48 | //[SCENARIO #0002] Assign non-existing lookup value to customer 49 | Initialize(); 50 | 51 | //[GIVEN] A non-existing lookup value value 52 | LookupValueCode := 'SC #0002'; 53 | //[GIVEN] A customer record variable 54 | // See local variable Customer 55 | 56 | //[WHEN] Set non-existing lookup value on customer 57 | asserterror SetLookupValueOnCustomer(Customer, LookupValueCode, DoNotModify()); 58 | 59 | //[THEN] Non existing lookup value error thrown 60 | VerifyNonExistingLookupValueError(LookupValueCode); 61 | end; 62 | 63 | [Test] 64 | [HandlerFunctions('HandleConfigTemplates')] 65 | procedure AssignLookupValueToCustomerCard() 66 | //[FEATURE] LookupValue UT Customer UI 67 | var 68 | CustomerCard: TestPage "Customer Card"; 69 | CustomerNo: Code[20]; 70 | LookupValueCode: Code[10]; 71 | begin 72 | //[SCENARIO #0003] Assign lookup value on customer card 73 | Initialize(); 74 | 75 | //[GIVEN] A lookup value 76 | LookupValueCode := CreateLookupValueCode(); 77 | //[GIVEN] A customer card 78 | CreateCustomerCard(CustomerCard); 79 | 80 | //[WHEN] Set lookup value on customer card 81 | CustomerNo := SetLookupValueOnCustomerCard(CustomerCard, LookupValueCode); 82 | 83 | //[THEN] Customer has lookup value field populated 84 | VerifyLookupValueOnCustomer(CustomerNo, LookupValueCode); 85 | end; 86 | 87 | local procedure Initialize() 88 | begin 89 | LibraryTestInitialize.OnTestInitialize(Codeunit::"LookupValue UT Customer"); 90 | 91 | if isInitialized then 92 | exit; 93 | LibraryTestInitialize.OnBeforeTestSuiteInitialize(Codeunit::"LookupValue UT Customer"); 94 | 95 | isInitialized := true; 96 | Commit(); 97 | 98 | LibraryTestInitialize.OnAfterTestSuiteInitialize(Codeunit::"LookupValue UT Customer"); 99 | end; 100 | 101 | local procedure CreateLookupValueCode(): Code[10] 102 | begin 103 | exit(LibraryLookupValue.CreateLookupValueCode()) 104 | end; 105 | 106 | local procedure CreateCustomer(var Customer: record Customer) 107 | begin 108 | LibrarySales.CreateCustomer(Customer); 109 | end; 110 | 111 | local procedure CreateCustomerCard(var CustomerCard: TestPage "Customer Card") 112 | begin 113 | CustomerCard.OpenNew(); 114 | end; 115 | 116 | local procedure SetLookupValueOnCustomer(var Customer: record Customer; LookupValueCode: Code[10]; CallModify: boolean) 117 | begin 118 | with Customer do begin 119 | Validate("Lookup Value Code", LookupValueCode); 120 | If CallModify then 121 | Modify(); 122 | end; 123 | end; 124 | 125 | local procedure DoModify(): Boolean 126 | begin 127 | exit(true) 128 | end; 129 | 130 | local procedure DoNotModify(): Boolean 131 | begin 132 | exit(false) 133 | end; 134 | 135 | local procedure SetLookupValueOnCustomerCard(var CustomerCard: TestPage "Customer Card"; LookupValueCode: Code[10]) CustomerNo: Code[20] 136 | begin 137 | with CustomerCard do begin 138 | // 139 | Assert.IsFalse("Lookup Value Code".Editable(), ''); 140 | // 141 | "Lookup Value Code".SetValue(LookupValueCode); 142 | CustomerNo := "No.".Value(); 143 | Close(); 144 | end; 145 | end; 146 | 147 | local procedure VerifyLookupValueOnCustomer(CustomerNo: Code[20]; LookupValueCode: Code[10]) 148 | var 149 | Customer: Record Customer; 150 | begin 151 | with Customer do begin 152 | Get(CustomerNo); 153 | Assert.AreEqual(LookupValueCode, "Lookup Value Code", LibraryMessages.GetFieldOnTableTxt(FieldCaption("Lookup Value Code"), TableCaption())); 154 | end; 155 | end; 156 | 157 | local procedure VerifyNonExistingLookupValueError(LookupValueCode: Code[10]) 158 | var 159 | Customer: Record Customer; 160 | LookupValue: Record LookupValue; 161 | begin 162 | with Customer do 163 | Assert.ExpectedError( 164 | LibraryMessages.GetValueCannotBeFoundInTableTxt( 165 | FieldCaption("Lookup Value Code"), 166 | TableCaption(), 167 | LookupValueCode, 168 | LookupValue.TableCaption())); 169 | end; 170 | 171 | [ModalPageHandler] 172 | procedure HandleConfigTemplates(var ConfigTemplates: TestPage "Config Templates") 173 | begin 174 | ConfigTemplates.OK.Invoke(); 175 | end; 176 | } -------------------------------------------------------------------------------- /demo/ATDD.TestScriptor_Demo.gif: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/fluxxus-nl/ATDD.TestScriptor/3a7341b3c173addacd95cd73d054a2eaac46081d/demo/ATDD.TestScriptor_Demo.gif -------------------------------------------------------------------------------- /demo/demo.ps1: -------------------------------------------------------------------------------- 1 | # FIXME: Install-Module ATDD.TestScriptor -Force 2 | Import-Module ./output/ATDD.TestScriptor/ATDD.TestScriptor.psd1 -Force 3 | 4 | $Features = @() 5 | 6 | $Features += 7 | Feature 'LookupValue UT Customer' { 8 | Scenario 1 'Check that label can be assigned to customer' { 9 | Given 'A label' 10 | Given 'A customer' 11 | When 'Assign label to customer' 12 | Then 'Customer has label field populated' 13 | } 14 | 15 | Scenario 2 'Check that label field table relation is validated for non-existing label on customer' { 16 | Given 'A non-existing label value' 17 | Given 'A customer record variable' 18 | When 'Assign non-existing label to customer' 19 | Then 'Non existing label error was thrown' 20 | } 21 | 22 | Scenario 3 'Check that label can be assigned on customer card' { 23 | Given 'A label' 24 | Given 'A customer card' 25 | When 'Assign label to customer card' 26 | Then 'Customer has label field populated' 27 | } 28 | } 29 | 30 | $Features += 31 | Feature 'Another Feature' { 32 | Scenario 1 'Oink' { 33 | Given Boink 34 | When Kloink 35 | Then Zoink 36 | } 37 | } 38 | 39 | $Features | ` 40 | ConvertTo-ALTestCodeunit ` 41 | -CodeunitID 81000 ` 42 | -CodeunitName 'LookupValue UT Customer' ` 43 | -InitializeFunction ` 44 | -GivenFunctionName "Create {0}" ` 45 | -ThenFunctionName "Verify {0}" 46 | -------------------------------------------------------------------------------- /docs/ConvertTo-ALTestCodeunit.md: -------------------------------------------------------------------------------- 1 | --- 2 | external help file: ATDD.TestScriptor.dll-Help.xml 3 | Module Name: ATDD.TestScriptor 4 | online version: 5 | schema: 2.0.0 6 | --- 7 | 8 | # ConvertTo-ALTestCodeunit 9 | 10 | ## SYNOPSIS 11 | Converts one or more test features to an AL codeunit. 12 | 13 | ## SYNTAX 14 | 15 | ``` 16 | ConvertTo-ALTestCodeunit [-CodeunitID] [-CodeunitName] [-InitializeFunction] 17 | [-Feature ] [-GivenFunctionName ] [-WhenFunctionName ] 18 | [-ThenFunctionName ] [] 19 | ``` 20 | 21 | ## DESCRIPTION 22 | Converts one or more test features to an AL codeunit. Each **scenario** contained in a feature will result in 1 test function. Each **given**, **when** and **then** tag in a scenario will result in a helper function placeholder to be completed by manual AL coding. 23 | 24 | ## EXAMPLES 25 | 26 | ### Example 1 27 | ```powershell 28 | PS C:\> Feature 'My Feature' { Scenario 1 'My Scenario' { Given Foo; When Baz; Then Bar } } | ConvertTo-ALTestCodeunit -CodeunitID 81000 -CodeunitName 'My Test Codeunit' 29 | codeunit 81000 "My Test Codeunit" 30 | ``` 31 | 32 | ## PARAMETERS 33 | 34 | ### -CodeunitID 35 | ID of the new test codeunit 36 | 37 | ```yaml 38 | Type: Int32 39 | Parameter Sets: (All) 40 | Aliases: 41 | 42 | Required: True 43 | Position: 0 44 | Default value: None 45 | Accept pipeline input: False 46 | Accept wildcard characters: False 47 | ``` 48 | 49 | ### -CodeunitName 50 | Name of the new test codeunit 51 | 52 | ```yaml 53 | Type: String 54 | Parameter Sets: (All) 55 | Aliases: 56 | 57 | Required: True 58 | Position: 1 59 | Default value: None 60 | Accept pipeline input: False 61 | Accept wildcard characters: False 62 | ``` 63 | 64 | ### -Feature 65 | The feature(s) whose scenarios must be included in the test codeunit 66 | 67 | ```yaml 68 | Type: TestFeature[] 69 | Parameter Sets: (All) 70 | Aliases: 71 | 72 | Required: False 73 | Position: Named 74 | Default value: None 75 | Accept pipeline input: True (ByValue) 76 | Accept wildcard characters: False 77 | ``` 78 | 79 | ### -GivenFunctionName 80 | Specify the format for the AL function that is created for a Given element. Use the placeholder {0} to specify where you want the Given's situation description to go. Leaving a space between the placeholder and the rest of your text ensures that it's seen as a separate word, and therefore gets an initial capital letter when converting to title case, e.g. 'Create {0}' for a Given whose situation is 'a Customer' will lead to 'CreateACustomer' as the function name. 81 | 82 | ```yaml 83 | Type: String 84 | Parameter Sets: (All) 85 | Aliases: 86 | 87 | Required: False 88 | Position: Named 89 | Default value: None 90 | Accept pipeline input: False 91 | Accept wildcard characters: False 92 | ``` 93 | 94 | ### -InitializeFunction 95 | Include this switch if you want to have an Initialize function setup for the test codeunit 96 | 97 | ```yaml 98 | Type: SwitchParameter 99 | Parameter Sets: (All) 100 | Aliases: 101 | 102 | Required: False 103 | Position: Named 104 | Default value: None 105 | Accept pipeline input: False 106 | Accept wildcard characters: False 107 | ``` 108 | 109 | ### -ThenFunctionName 110 | Specify the format for the AL function that is created for a Then element. Use the placeholder {0} to specify where you want the Then's expected result description to go. Leaving a space between the placeholder and the rest of your text ensures that it's seen as a separate word, and therefore gets an initial capital letter when converting to title case, e.g. 'Verify {0}' for a Given whose situation is 'customer exists' will lead to 'VerifyCustomerExists' as the function name. 111 | 112 | ```yaml 113 | Type: String 114 | Parameter Sets: (All) 115 | Aliases: 116 | 117 | Required: False 118 | Position: Named 119 | Default value: None 120 | Accept pipeline input: False 121 | Accept wildcard characters: False 122 | ``` 123 | 124 | ### -WhenFunctionName 125 | Specify the format for the AL function that is created for a When element. Use the placeholder {0} to specify where you want the When's condition description to go. Leaving a space between the placeholder and the rest of your text ensures that it's seen as a separate word, and therefore gets an initial capital letter when converting to title case. 126 | ```yaml 127 | Type: String 128 | Parameter Sets: (All) 129 | Aliases: 130 | 131 | Required: False 132 | Position: Named 133 | Default value: None 134 | Accept pipeline input: False 135 | Accept wildcard characters: False 136 | ``` 137 | 138 | ### CommonParameters 139 | This cmdlet supports the common parameters: -Debug, -ErrorAction, -ErrorVariable, -InformationAction, -InformationVariable, -OutVariable, -OutBuffer, -PipelineVariable, -Verbose, -WarningAction, and -WarningVariable. For more information, see [about_CommonParameters](http://go.microsoft.com/fwlink/?LinkID=113216). 140 | 141 | ## INPUTS 142 | 143 | ### ATDD.TestScriptor.TestFeature[] 144 | ## OUTPUTS 145 | 146 | ### System.Object 147 | ## NOTES 148 | 149 | ## RELATED LINKS 150 | -------------------------------------------------------------------------------- /docs/New-ATDDCleanup.md: -------------------------------------------------------------------------------- 1 | --- 2 | external help file: ATDD.TestScriptor.dll-Help.xml 3 | Module Name: ATDD.TestScriptor 4 | online version: 5 | schema: 2.0.0 6 | --- 7 | 8 | # New-ATDDCleanup 9 | 10 | ## SYNOPSIS 11 | {{Fill in the Synopsis}} 12 | 13 | ## SYNTAX 14 | 15 | ``` 16 | New-ATDDCleanup [-Target] [] 17 | ``` 18 | 19 | ## DESCRIPTION 20 | {{Fill in the Description}} 21 | 22 | ## EXAMPLES 23 | 24 | ### Example 1 25 | ```powershell 26 | PS C:\> {{ Add example code here }} 27 | ``` 28 | 29 | {{ Add example description here }} 30 | 31 | ## PARAMETERS 32 | 33 | ### -Target 34 | {{Fill Target Description}} 35 | 36 | ```yaml 37 | Type: String 38 | Parameter Sets: (All) 39 | Aliases: 40 | 41 | Required: True 42 | Position: 0 43 | Default value: None 44 | Accept pipeline input: False 45 | Accept wildcard characters: False 46 | ``` 47 | 48 | ### CommonParameters 49 | This cmdlet supports the common parameters: -Debug, -ErrorAction, -ErrorVariable, -InformationAction, -InformationVariable, -OutVariable, -OutBuffer, -PipelineVariable, -Verbose, -WarningAction, and -WarningVariable. For more information, see [about_CommonParameters](http://go.microsoft.com/fwlink/?LinkID=113216). 50 | 51 | ## INPUTS 52 | 53 | ### None 54 | ## OUTPUTS 55 | 56 | ### System.Object 57 | ## NOTES 58 | 59 | ## RELATED LINKS 60 | -------------------------------------------------------------------------------- /docs/New-ATDDGiven.md: -------------------------------------------------------------------------------- 1 | --- 2 | external help file: ATDD.TestScriptor.dll-Help.xml 3 | Module Name: ATDD.TestScriptor 4 | online version: 5 | schema: 2.0.0 6 | --- 7 | 8 | # New-ATDDGiven 9 | 10 | ## SYNOPSIS 11 | {{Fill in the Synopsis}} 12 | 13 | ## SYNTAX 14 | 15 | ``` 16 | New-ATDDGiven [-Situation] [] 17 | ``` 18 | 19 | ## DESCRIPTION 20 | {{Fill in the Description}} 21 | 22 | ## EXAMPLES 23 | 24 | ### Example 1 25 | ```powershell 26 | PS C:\> {{ Add example code here }} 27 | ``` 28 | 29 | {{ Add example description here }} 30 | 31 | ## PARAMETERS 32 | 33 | ### -Situation 34 | {{Fill Situation Description}} 35 | 36 | ```yaml 37 | Type: String 38 | Parameter Sets: (All) 39 | Aliases: 40 | 41 | Required: True 42 | Position: 0 43 | Default value: None 44 | Accept pipeline input: False 45 | Accept wildcard characters: False 46 | ``` 47 | 48 | ### CommonParameters 49 | This cmdlet supports the common parameters: -Debug, -ErrorAction, -ErrorVariable, -InformationAction, -InformationVariable, -OutVariable, -OutBuffer, -PipelineVariable, -Verbose, -WarningAction, and -WarningVariable. For more information, see [about_CommonParameters](http://go.microsoft.com/fwlink/?LinkID=113216). 50 | 51 | ## INPUTS 52 | 53 | ### None 54 | ## OUTPUTS 55 | 56 | ### System.Object 57 | ## NOTES 58 | 59 | ## RELATED LINKS 60 | -------------------------------------------------------------------------------- /docs/New-ATDDTestFeature.md: -------------------------------------------------------------------------------- 1 | --- 2 | external help file: ATDD.TestScriptor.dll-Help.xml 3 | Module Name: ATDD.TestScriptor 4 | online version: 5 | schema: 2.0.0 6 | --- 7 | 8 | # New-ATDDTestFeature 9 | 10 | ## SYNOPSIS 11 | {{Fill in the Synopsis}} 12 | 13 | ## SYNTAX 14 | 15 | ``` 16 | New-ATDDTestFeature [-Name] [[-Scenarios] ] [] 17 | ``` 18 | 19 | ## DESCRIPTION 20 | {{Fill in the Description}} 21 | 22 | ## EXAMPLES 23 | 24 | ### Example 1 25 | ```powershell 26 | PS C:\> {{ Add example code here }} 27 | ``` 28 | 29 | {{ Add example description here }} 30 | 31 | ## PARAMETERS 32 | 33 | ### -Name 34 | {{Fill Name Description}} 35 | 36 | ```yaml 37 | Type: String 38 | Parameter Sets: (All) 39 | Aliases: 40 | 41 | Required: True 42 | Position: 0 43 | Default value: None 44 | Accept pipeline input: False 45 | Accept wildcard characters: False 46 | ``` 47 | 48 | ### -Scenarios 49 | {{Fill Scenarios Description}} 50 | 51 | ```yaml 52 | Type: ScriptBlock 53 | Parameter Sets: (All) 54 | Aliases: 55 | 56 | Required: False 57 | Position: 1 58 | Default value: None 59 | Accept pipeline input: False 60 | Accept wildcard characters: False 61 | ``` 62 | 63 | ### CommonParameters 64 | This cmdlet supports the common parameters: -Debug, -ErrorAction, -ErrorVariable, -InformationAction, -InformationVariable, -OutVariable, -OutBuffer, -PipelineVariable, -Verbose, -WarningAction, and -WarningVariable. For more information, see [about_CommonParameters](http://go.microsoft.com/fwlink/?LinkID=113216). 65 | 66 | ## INPUTS 67 | 68 | ### None 69 | ## OUTPUTS 70 | 71 | ### System.Object 72 | ## NOTES 73 | 74 | ## RELATED LINKS 75 | -------------------------------------------------------------------------------- /docs/New-ATDDTestScenario.md: -------------------------------------------------------------------------------- 1 | --- 2 | external help file: ATDD.TestScriptor.dll-Help.xml 3 | Module Name: ATDD.TestScriptor 4 | online version: 5 | schema: 2.0.0 6 | --- 7 | 8 | # New-ATDDTestScenario 9 | 10 | ## SYNOPSIS 11 | {{Fill in the Synopsis}} 12 | 13 | ## SYNTAX 14 | 15 | ``` 16 | New-ATDDTestScenario [-ID] [-Name] [[-Elements] ] [] 17 | ``` 18 | 19 | ## DESCRIPTION 20 | {{Fill in the Description}} 21 | 22 | ## EXAMPLES 23 | 24 | ### Example 1 25 | ```powershell 26 | PS C:\> {{ Add example code here }} 27 | ``` 28 | 29 | {{ Add example description here }} 30 | 31 | ## PARAMETERS 32 | 33 | ### -Elements 34 | {{Fill Elements Description}} 35 | 36 | ```yaml 37 | Type: ScriptBlock 38 | Parameter Sets: (All) 39 | Aliases: 40 | 41 | Required: False 42 | Position: 2 43 | Default value: None 44 | Accept pipeline input: False 45 | Accept wildcard characters: False 46 | ``` 47 | 48 | ### -ID 49 | {{Fill ID Description}} 50 | 51 | ```yaml 52 | Type: Int32 53 | Parameter Sets: (All) 54 | Aliases: 55 | 56 | Required: True 57 | Position: 0 58 | Default value: None 59 | Accept pipeline input: False 60 | Accept wildcard characters: False 61 | ``` 62 | 63 | ### -Name 64 | {{Fill Name Description}} 65 | 66 | ```yaml 67 | Type: String 68 | Parameter Sets: (All) 69 | Aliases: 70 | 71 | Required: True 72 | Position: 1 73 | Default value: None 74 | Accept pipeline input: False 75 | Accept wildcard characters: False 76 | ``` 77 | 78 | ### CommonParameters 79 | This cmdlet supports the common parameters: -Debug, -ErrorAction, -ErrorVariable, -InformationAction, -InformationVariable, -OutVariable, -OutBuffer, -PipelineVariable, -Verbose, -WarningAction, and -WarningVariable. For more information, see [about_CommonParameters](http://go.microsoft.com/fwlink/?LinkID=113216). 80 | 81 | ## INPUTS 82 | 83 | ### None 84 | ## OUTPUTS 85 | 86 | ### System.Object 87 | ## NOTES 88 | 89 | ## RELATED LINKS 90 | -------------------------------------------------------------------------------- /docs/New-ATDDThen.md: -------------------------------------------------------------------------------- 1 | --- 2 | external help file: ATDD.TestScriptor.dll-Help.xml 3 | Module Name: ATDD.TestScriptor 4 | online version: 5 | schema: 2.0.0 6 | --- 7 | 8 | # New-ATDDThen 9 | 10 | ## SYNOPSIS 11 | {{Fill in the Synopsis}} 12 | 13 | ## SYNTAX 14 | 15 | ``` 16 | New-ATDDThen [-ExpectedResult] [] 17 | ``` 18 | 19 | ## DESCRIPTION 20 | {{Fill in the Description}} 21 | 22 | ## EXAMPLES 23 | 24 | ### Example 1 25 | ```powershell 26 | PS C:\> {{ Add example code here }} 27 | ``` 28 | 29 | {{ Add example description here }} 30 | 31 | ## PARAMETERS 32 | 33 | ### -ExpectedResult 34 | {{Fill ExpectedResult Description}} 35 | 36 | ```yaml 37 | Type: String 38 | Parameter Sets: (All) 39 | Aliases: 40 | 41 | Required: True 42 | Position: 0 43 | Default value: None 44 | Accept pipeline input: False 45 | Accept wildcard characters: False 46 | ``` 47 | 48 | ### CommonParameters 49 | This cmdlet supports the common parameters: -Debug, -ErrorAction, -ErrorVariable, -InformationAction, -InformationVariable, -OutVariable, -OutBuffer, -PipelineVariable, -Verbose, -WarningAction, and -WarningVariable. For more information, see [about_CommonParameters](http://go.microsoft.com/fwlink/?LinkID=113216). 50 | 51 | ## INPUTS 52 | 53 | ### None 54 | ## OUTPUTS 55 | 56 | ### System.Object 57 | ## NOTES 58 | 59 | ## RELATED LINKS 60 | -------------------------------------------------------------------------------- /docs/New-ATDDWhen.md: -------------------------------------------------------------------------------- 1 | --- 2 | external help file: ATDD.TestScriptor.dll-Help.xml 3 | Module Name: ATDD.TestScriptor 4 | online version: 5 | schema: 2.0.0 6 | --- 7 | 8 | # New-ATDDWhen 9 | 10 | ## SYNOPSIS 11 | {{Fill in the Synopsis}} 12 | 13 | ## SYNTAX 14 | 15 | ``` 16 | New-ATDDWhen [-Condition] [] 17 | ``` 18 | 19 | ## DESCRIPTION 20 | {{Fill in the Description}} 21 | 22 | ## EXAMPLES 23 | 24 | ### Example 1 25 | ```powershell 26 | PS C:\> {{ Add example code here }} 27 | ``` 28 | 29 | {{ Add example description here }} 30 | 31 | ## PARAMETERS 32 | 33 | ### -Condition 34 | {{Fill Condition Description}} 35 | 36 | ```yaml 37 | Type: String 38 | Parameter Sets: (All) 39 | Aliases: 40 | 41 | Required: True 42 | Position: 0 43 | Default value: None 44 | Accept pipeline input: False 45 | Accept wildcard characters: False 46 | ``` 47 | 48 | ### CommonParameters 49 | This cmdlet supports the common parameters: -Debug, -ErrorAction, -ErrorVariable, -InformationAction, -InformationVariable, -OutVariable, -OutBuffer, -PipelineVariable, -Verbose, -WarningAction, and -WarningVariable. For more information, see [about_CommonParameters](http://go.microsoft.com/fwlink/?LinkID=113216). 50 | 51 | ## INPUTS 52 | 53 | ### None 54 | ## OUTPUTS 55 | 56 | ### System.Object 57 | ## NOTES 58 | 59 | ## RELATED LINKS 60 | -------------------------------------------------------------------------------- /docs/about_ATDD.TestScriptor.md: -------------------------------------------------------------------------------- 1 | # ATDD.TestScriptor 2 | ## about_ATDD.TestScriptor 3 | 4 | # SHORT DESCRIPTION 5 | Define with ATDD.TestScriptor ATDD test scenarios and convert it into AL code 6 | 7 | # LONG DESCRIPTION 8 | The Acceptance Test-Driven Development test scriptor allows the user to define in a managed matter ATDD test scenarios and convert it into a code structure to facilate fast test code development. At this moment this conversion is only implemented for .al 9 | 10 | ## Optional Subtopics 11 | An ATDD pattern is defined by so called tags: 12 | - FEATURE: defines what feature(s) the test or collection of test cases is testing 13 | - SCENARIO: defines for a single test the scenario being teste 14 | - GIVEN: defines what data setup is needed; a test case can have multiple GIVEN tags when data setup is more complex 15 | - WHEN: defines the action under test; each test case should have only one WHEN tag 16 | - THEN: defines the result of the action, or more specifically the verification of the result; if multiple results apply, multiple THEN tags will be needed 17 | 18 | 19 | # EXAMPLES 20 | {{ Code or descriptive examples of how to leverage the functions described. }} 21 | 22 | # NOTE 23 | {{ Note Placeholder - Additional information that a user needs to know.}} 24 | 25 | # TROUBLESHOOTING NOTE 26 | {{ Troubleshooting Placeholder - Warns users of bugs}} 27 | 28 | {{ Explains behavior that is likely to change with fixes }} 29 | 30 | # SEE ALSO 31 | {{ See also placeholder }} 32 | 33 | {{ You can also list related articles, blogs, and video URLs. }} 34 | 35 | # KEYWORDS 36 | {{List alternate names or titles for this topic that readers might use.}} 37 | 38 | - {{ Keyword Placeholder }} 39 | - {{ Keyword Placeholder }} 40 | - {{ Keyword Placeholder }} 41 | - {{ Keyword Placeholder }} 42 | -------------------------------------------------------------------------------- /format.ps1xml: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | Scenario 5 | 6 | 7 | 8 | 9 | 10 | $_.ToString() 11 | 12 | 13 | 14 | 4 15 | 16 | 17 | Elements 18 | 19 | Element 20 | 21 | 22 | 23 | 24 | 25 | 26 | 27 | 28 | 29 | Element 30 | 31 | 32 | 33 | 34 | 35 | $_.ToString() 36 | 37 | 38 | 39 | 40 | 41 | 42 | 43 | 44 | 45 | 46 | Default 47 | 48 | ATDD.TestScriptor.TestFeature 49 | 50 | 51 | 52 | 53 | 54 | 55 | $_.ToString() 56 | 57 | 58 | 59 | 4 60 | 61 | 62 | Scenarios 63 | 64 | Scenario 65 | 66 | 67 | 68 | 69 | 70 | 71 | 72 | 73 | 74 | -------------------------------------------------------------------------------- /manifest.psd1: -------------------------------------------------------------------------------- 1 | # 2 | # Module manifest for module 'manifest' 3 | # 4 | # Generated by: Jan Hoek 5 | # 6 | # Generated on: 20/03/2019 7 | # 8 | 9 | @{ 10 | 11 | # Script module or binary module file associated with this manifest. 12 | RootModule = 'ATDD.TestScriptor.dll' 13 | 14 | # Version number of this module. 15 | ModuleVersion = '0.1.3' 16 | 17 | # Supported PSEditions 18 | # CompatiblePSEditions = @() 19 | 20 | # ID used to uniquely identify this module 21 | GUID = '7cef471c-3b16-4620-8b74-5a86c520d989' 22 | 23 | # Author of this module 24 | Author = 'Jan Hoek/Luc van Vugt/Peter Conijn' 25 | 26 | # Company or vendor of this module 27 | CompanyName = 'fluxxus.nl' 28 | 29 | # Copyright statement for this module 30 | Copyright = 'Copyright (c) 2024 fluxxus.nl' 31 | 32 | # Description of the functionality provided by this module 33 | Description = 'Acceptance Test-Driven Development test scriptor' 34 | 35 | # Minimum version of the PowerShell engine required by this module 36 | # PowerShellVersion = '' 37 | 38 | # Name of the PowerShell host required by this module 39 | # PowerShellHostName = '' 40 | 41 | # Minimum version of the PowerShell host required by this module 42 | # PowerShellHostVersion = '' 43 | 44 | # Minimum version of Microsoft .NET Framework required by this module. This prerequisite is valid for the PowerShell Desktop edition only. 45 | # DotNetFrameworkVersion = '' 46 | 47 | # Minimum version of the common language runtime (CLR) required by this module. This prerequisite is valid for the PowerShell Desktop edition only. 48 | # CLRVersion = '' 49 | 50 | # Processor architecture (None, X86, Amd64) required by this module 51 | # ProcessorArchitecture = '' 52 | 53 | # Modules that must be imported into the global environment prior to importing this module 54 | # RequiredModules = @() 55 | 56 | # Assemblies that must be loaded prior to importing this module 57 | # RequiredAssemblies = @() 58 | 59 | # Script files (.ps1) that are run in the caller's environment prior to importing this module. 60 | # ScriptsToProcess = @() 61 | 62 | # Type files (.ps1xml) to be loaded when importing this module 63 | # TypesToProcess = @() 64 | 65 | # Format files (.ps1xml) to be loaded when importing this module 66 | FormatsToProcess = 'ATDD.TestScriptor.format.ps1xml' 67 | 68 | # Modules to import as nested modules of the module specified in RootModule/ModuleToProcess 69 | # NestedModules = @() 70 | 71 | # Functions to export from this module, for best performance, do not use wildcards and do not delete the entry, use an empty array if there are no functions to export. 72 | FunctionsToExport = '*' 73 | 74 | # Cmdlets to export from this module, for best performance, do not use wildcards and do not delete the entry, use an empty array if there are no cmdlets to export. 75 | CmdletsToExport = 'New-ATDDGiven', 'New-ATDDTestFeature', 'New-ATDDTestScenario', 'New-ATDDThen', 76 | 'New-ATDDWhen', 'ConvertTo-ALTestCodeunit', 'New-ATDDCleanup' 77 | 78 | # Variables to export from this module 79 | VariablesToExport = '*' 80 | 81 | # Aliases to export from this module, for best performance, do not use wildcards and do not delete the entry, use an empty array if there are no aliases to export. 82 | AliasesToExport = 'Cleanup', 'Given', 'Feature', 'Scenario', 'Then', 'When' 83 | 84 | # DSC resources to export from this module 85 | # DscResourcesToExport = @() 86 | 87 | # List of all modules packaged with this module 88 | # ModuleList = @() 89 | 90 | # List of all files packaged with this module 91 | # FileList = @() 92 | 93 | # Private data to pass to the module specified in RootModule/ModuleToProcess. This may also contain a PSData hashtable with additional module metadata used by PowerShell. 94 | PrivateData = @{ 95 | 96 | PSData = @{ 97 | 98 | # Tags applied to this module. These help with module discovery in online galleries. 99 | # Tags = @() 100 | 101 | # A URL to the license for this module. 102 | LicenseUri = 'https://github.com/fluxxus-nl/ATDD.TestScriptor/blob/master/LICENSE' 103 | 104 | # A URL to the main website for this project. 105 | ProjectUri = 'https://github.com/fluxxus-nl/ATDD.TestScriptor' 106 | 107 | # A URL to an icon representing this module. 108 | IconUri = 'https://github.com/fluxxus-nl.png' 109 | 110 | # ReleaseNotes of this module 111 | # ReleaseNotes = '' 112 | 113 | } # End of PSData hashtable 114 | 115 | } # End of PrivateData hashtable 116 | 117 | # HelpInfo URI of this module 118 | # HelpInfoURI = '' 119 | 120 | # Default prefix for commands exported from this module. Override the default prefix using Import-Module -Prefix. 121 | # DefaultCommandPrefix = '' 122 | 123 | } 124 | 125 | --------------------------------------------------------------------------------