$npx -y skills add tebjan/vvvv-skills --skill vvvv-testingSet up and run automated tests for vvvv gamma packages and C# nodes -- VL.TestFramework with NUnit for library/package authors (CI-ready), test .vl patches with assertion nodes, and lightweight agent-driven test workflows. Use when writing tests for vvvv packages, setting up test
| 1 | # Testing vvvv gamma Projects |
| 2 | |
| 3 | ## Two Testing Approaches |
| 4 | |
| 5 | | Approach | Use Case | Setup | |
| 6 | |----------|----------|-------| |
| 7 | | **VL.TestFramework** (NUnit) | Package/library authors, CI integration | .csproj test project with NUnit | |
| 8 | | **Agent test workflow** | Quick verification, ad-hoc debugging | Create test .vl patch, launch vvvv, check results | |
| 9 | |
| 10 | ## VL.TestFramework (NUnit) |
| 11 | |
| 12 | ### Test Project Setup |
| 13 | |
| 14 | Create a test .csproj referencing VL.TestFramework: |
| 15 | |
| 16 | ```xml |
| 17 | <Project Sdk="Microsoft.NET.Sdk"> |
| 18 | <PropertyGroup> |
| 19 | <TargetFramework>net8.0-windows</TargetFramework> |
| 20 | </PropertyGroup> |
| 21 | <ItemGroup> |
| 22 | <PackageReference Include="NUnit" Version="4.*" /> |
| 23 | <PackageReference Include="NUnit3TestAdapter" Version="4.*" /> |
| 24 | <PackageReference Include="Microsoft.NET.Test.Sdk" Version="17.*" /> |
| 25 | </ItemGroup> |
| 26 | <ItemGroup> |
| 27 | <ProjectReference Include="..\path\to\VL.TestFramework.csproj" /> |
| 28 | <!-- OR if using installed vvvv: --> |
| 29 | <!-- Reference VL.TestFramework.dll from vvvv install dir --> |
| 30 | </ItemGroup> |
| 31 | </Project> |
| 32 | ``` |
| 33 | |
| 34 | ### Minimal Test Class |
| 35 | |
| 36 | ```csharp |
| 37 | using NUnit.Framework; |
| 38 | using VL.TestFramework; |
| 39 | |
| 40 | [TestFixture] |
| 41 | public class MyPackageTests |
| 42 | { |
| 43 | TestEnvironment testEnvironment; |
| 44 | |
| 45 | // Important: Don't use async Task here (NUnit sync context issue) |
| 46 | [OneTimeSetUp] |
| 47 | public void Setup() |
| 48 | { |
| 49 | var assemblyPath = typeof(MyPackageTests).Assembly.Location; |
| 50 | var searchPaths = new[] { "path/to/your/package" }; |
| 51 | testEnvironment = TestEnvironmentLoader.Load(assemblyPath, searchPaths); |
| 52 | } |
| 53 | |
| 54 | [OneTimeTearDown] |
| 55 | public void TearDown() |
| 56 | { |
| 57 | testEnvironment?.Dispose(); |
| 58 | testEnvironment = null; |
| 59 | } |
| 60 | |
| 61 | [Test] |
| 62 | public async Task MyPatchCompilesWithoutErrors() |
| 63 | { |
| 64 | await testEnvironment.LoadAndTestAsync("path/to/MyPatch.vl"); |
| 65 | } |
| 66 | |
| 67 | [Test] |
| 68 | public async Task MyPatchCompilesAndRuns() |
| 69 | { |
| 70 | await testEnvironment.LoadAndTestAsync( |
| 71 | "path/to/MyPatch.vl", |
| 72 | runEntryPoint: true); |
| 73 | } |
| 74 | } |
| 75 | ``` |
| 76 | |
| 77 | ### Key API |
| 78 | |
| 79 | - `TestEnvironmentLoader.Load(assemblyPath, searchPaths)` -- Create test environment. One per test class (expensive). |
| 80 | - `testEnvironment.LoadAndTestAsync(filePath)` -- Load .vl document, check for compilation errors. |
| 81 | - `testEnvironment.LoadAndTestAsync(filePath, runEntryPoint: true)` -- Also execute the entry point (Create + Update + Dispose). |
| 82 | - `testEnvironment.GetPackages()` -- Discover all packages and their source/help/test files. |
| 83 | - `testEnvironment.Host.LoadAndCompileAsync(filePath)` -- Load and compile without running (for custom assertions). |
| 84 | - `testEnvironment.Host.GetTargetCompilationAsync(filePath)` -- Get the C# compilation for inspection. |
| 85 | |
| 86 | For the full API reference, see [test-framework-reference.md](test-framework-reference.md). |
| 87 | |
| 88 | ### Test Discovery Conventions |
| 89 | |
| 90 | The VL.TestFramework automatically discovers tests: |
| 91 | |
| 92 | - **Test documents**: `.vl` files in `tests/` folders under package directories |
| 93 | - **Help patches**: `.vl` files in `help/` folders (tested for compilation only) |
| 94 | - **Test nodes**: Process or operation nodes ending in `Test` or `Tests` within test documents are individually compiled and executed |
| 95 | |
| 96 | File discovery pattern: |
| 97 | ``` |
| 98 | VL.MyPackage/ |
| 99 | tests/ |
| 100 | MyFeatureTest.vl <-- auto-discovered test document |
| 101 | IntegrationTests.vl <-- auto-discovered test document |
| 102 | help/ |
| 103 | HowTo Use Feature.vl <-- tested for compilation errors |
| 104 | ``` |
| 105 | |
| 106 | ### Running Tests |
| 107 | |
| 108 | ```shell |
| 109 | # Run all tests |
| 110 | dotnet test |
| 111 | |
| 112 | # Run specific test |
| 113 | dotnet test --filter "MyPatchCompilesWithoutErrors" |
| 114 | |
| 115 | # Via Nuke build system (if available) |
| 116 | ./build.ps1 --target Test |
| 117 | ``` |
| 118 | |
| 119 | ## Test Nodes (VL Patch Assertions) |
| 120 | |
| 121 | Use these nodes inside .vl test patches to assert behavior. Available under `VL.Lib.Basics.Test.TestNodes`: |
| 122 | |
| 123 | ```csharp |
| 124 | // In VL patches, these are available as nodes: |
| 125 | TestNodes.Assert(condition, "message") // General assertion |
| 126 | TestNodes.AreEqual(expected, actual) // Value equality |
| 127 | TestNodes.AreNotEqual(expected, actual) // Value inequality |
| 128 | TestNodes.IsNotNull(input) // Null check |
| 129 | TestNodes.AreSequenceEqual(expected, actual) // Collection equality |
| 130 | TestNodes.AssertElementHasError(elementGuid) // Verify element has compile error |
| 131 | TestNodes.AssertElementHasNoError(elementGuid) // Verify element has no compile error |
| 132 | ``` |
| 133 | |
| 134 | Assertions throw `AssertionException` on failure, which the test runner catches and repo |