# Run all tests in assemblyvstest.console.exe x64\Debug\FancyZonesUnitTests\FancyZonesUnitTests.dll# Run specific testvstest.console.exe x64\Debug\FancyZonesUnitTests\FancyZonesUnitTests.dll /Tests:TestName# Run tests matching filtervstest.console.exe x64\Debug\FancyZonesUnitTests\FancyZonesUnitTests.dll /TestCaseFilter:"Priority=1"
using Microsoft.VisualStudio.TestTools.UnitTesting;namespace PowerToys.ModuleName.UnitTests{ [TestClass] public class ModuleFeatureTests { [TestMethod] public void TestMethodName_Scenario_ExpectedResult() { // Arrange var module = new ModuleClass(); var input = "test input"; // Act var result = module.ProcessInput(input); // Assert Assert.IsNotNull(result); Assert.AreEqual("expected output", result); } [TestMethod] [ExpectedException(typeof(ArgumentNullException))] public void TestMethodName_NullInput_ThrowsException() { // Arrange var module = new ModuleClass(); // Act module.ProcessInput(null); // Should throw } }}
<Project Sdk="Microsoft.NET.Sdk"> <Import Project="..\..\..\Common.Dotnet.CsWinRT.props" /> <PropertyGroup> <ProjectGuid>{YOUR-GUID-HERE}</ProjectGuid> <RootNamespace>PowerToys.YourModule.UITests</RootNamespace> <AssemblyName>PowerToys.YourModule.UITests</AssemblyName> <IsPackable>false</IsPackable> <IsTestProject>true</IsTestProject> <Nullable>enable</Nullable> <OutputType>Library</OutputType> <!-- This is a UI test, so don't run as part of MSBuild --> <RunVSTest>false</RunVSTest> </PropertyGroup> <PropertyGroup> <OutputPath>$(SolutionDir)$(Platform)\$(Configuration)\tests\YourModule.UITests\</OutputPath> </PropertyGroup> <ItemGroup> <PackageReference Include="MSTest" /> <ProjectReference Include="..\..\..\common\UITestAutomation\UITestAutomation.csproj" /> </ItemGroup></Project>
// By AutomationIdvar element = this.Find("ElementAutomationId");// By type and namevar button = this.Find<Button>("ButtonName");// Check if existsbool exists = this.Has<TextBox>("TextBoxName");// Check for single elementbool hasOne = this.HasOne<ComboBox>("ComboBoxName");
buildSource: - latestMainOfficialBuild # Test against latest release - buildNow # Test current source code - specificBuildId # Test specific buildspecificBuildId: "12345" # Build ID when using specificBuildIduiTestModules: - 'UITests-FancyZones' # Run specific module tests - 'MouseUtils.UITests' # Or multiple modules - [] # Empty = run all tests
using SharpFuzz;using Microsoft.OneFuzz.SDK;public class FuzzTarget{ public static void FuzzMethod(string input) { try { // Code to test with fuzzing input var result = ProcessInput(input); } catch (Exception ex) { // Expected exceptions should be caught // Unexpected exceptions will be reported } } public static void Main(string[] args) { // SharpFuzz entry point Fuzzer.Run(() => { var input = Console.ReadLine(); FuzzMethod(input); }); }}
# Build fuzz targetdotnet build src\modules\<Module>\FuzzTests\# Run with SharpFuzzsharpfuzz .\x64\Debug\<Module>.FuzzTests.dll# Provide seed corpus (optional)sharpfuzz .\x64\Debug\<Module>.FuzzTests.dll --corpus=.\testdata\corpus
// Add delays for visual inspectionSystem.Threading.Thread.Sleep(2000);// Take screenshots on failureif (!condition){ var screenshot = this.TakeScreenshot(); this.TestContext.AddResultFile(screenshot); Assert.Fail("Condition not met");}