Psx Test Generator
A Visual Studio extension that restores the "Create Unit Test Project" context menu option that Microsoft removed from recent versions of Visual Studio.
Features
Right-click in any of these locations to create a fully configured MSTest test project:
Solution Explorer — Project Node
Right-click any project → Create Unit Test Project
Creates a test project referencing the selected project with a placeholder test class.

Solution Explorer — C# File
Right-click any .cs file → Create Unit Test Project
Creates a test project and scaffolds test classes with method stubs for every public class found in the file.

Code Editor
Right-click inside a .cs file → Create Unit Test Project
Creates a test project and scaffolds a test class for the class at your cursor position. Public methods are detected and stubbed automatically.

What Gets Generated
Test Project (.csproj)
The generated project follows Psx workspace conventions:
<Project Sdk="Microsoft.NET.Sdk">
<PropertyGroup Label="Globals">
<SccProjectName>SAK</SccProjectName>
<SccProvider>SAK</SccProvider>
<SccAuxPath>SAK</SccAuxPath>
<SccLocalPath>SAK</SccLocalPath>
</PropertyGroup>
<PropertyGroup>
<TargetFramework>net10.0</TargetFramework>
<LangVersion>latest</LangVersion>
<Nullable>enable</Nullable>
<ImplicitUsings>enable</ImplicitUsings>
<RootNamespace>Psx.Example.Tests</RootNamespace>
<IsPackable>false</IsPackable>
<IsTestProject>true</IsTestProject>
</PropertyGroup>
<ItemGroup>
<PackageReference Include="MSTest" Version="3.8.3" />
</ItemGroup>
<ItemGroup>
<ProjectReference Include="..\Psx.Example\Psx.Example.csproj" />
</ItemGroup>
</Project>
- Location: Sibling folder in
Dev/ (e.g., Psx.Example.Tests/ alongside Psx.Example/)
- Target framework: Auto-detected from the source project (platform suffixes like
-windows are stripped)
- TFVC: SAK properties included;
.slnx TFVC entries updated automatically
- Project reference: Points back to the source project via relative path
Test Classes
When source analysis is available (file or editor context), test stubs are scaffolded from your code:
namespace Psx.Example.Tests;
[TestClass]
public class OrderServiceTests
{
[TestMethod]
public void PlaceOrder_Should()
{
// Arrange
// Act
// Assert
Assert.Inconclusive("Not implemented");
}
[TestMethod]
public async Task CancelOrderAsync_Should()
{
// Arrange
// Act
// Assert
Assert.Inconclusive("Not implemented");
}
}
- One test method stub per public method on the source class
- Async methods generate
async Task test methods
Assert.Inconclusive marks stubs as incomplete (visible in Test Explorer without failing the build)
- When no source analysis is available (project-level), a single placeholder test class is created
Installation
From VSIX File
- Build the project (see below)
- Find
PsxTestGenerator.vsix in bin\Release\net48\
- Double-click the
.vsix file to install
- Restart Visual Studio
Supported Versions
- Visual Studio 2022 (17.8 and later)
- Visual Studio 2025
- Visual Studio 2026
Community, Professional, and Enterprise editions are all supported.
Building
Prerequisites
- Visual Studio 2022 or later with the Visual Studio extension development workload
- .NET Framework 4.8 targeting pack
Build
dotnet build PsxTestGenerator\PsxTestGenerator.csproj -c Release
Debug
Press F5 in Visual Studio to launch the Experimental Instance with the extension loaded. The project is pre-configured with:
StartAction: Program
StartProgram: $(DevEnvDir)devenv.exe
StartArguments: /rootsuffix Exp
Behavior Notes
- Duplicate detection: If a test project already exists at the expected path, a warning is shown and the existing project is added to the solution (if not already present).
.slnx support: The extension updates TFVC source control properties (SccNumberOfProjects, SccLocalPath, SccProjectName, SccProjectUniqueName) in .slnx solution files automatically.
.Designer.cs files: Excluded from the code editor and file context menus since they contain generated code.
- Visibility: The context menu items only appear on C# files and project nodes — they are hidden for other file types.
Project Structure
PsxTestGenerator/
├── source.extension.vsixmanifest — VSIX metadata and installation targets
├── PsxTestGeneratorPackage.cs — Extension entry point (AsyncPackage)
├── PackageGuids.cs — GUIDs for commands and menus
├── Vsix.cs — Version and metadata constants
├── Commands/
│ ├── PsxTestGeneratorCommands.vsct — Command table (menu placements)
│ ├── CreateTestFromProjectCommand.cs
│ ├── CreateTestFromFileCommand.cs
│ └── CreateTestFromEditorCommand.cs
├── Services/
│ ├── TestProjectService.cs — Project creation and solution integration
│ ├── RoslynAnalysisService.cs — Source code analysis via Roslyn
│ └── TemplateService.cs — Test class code generation
├── Models/
│ ├── SourceClassInfo.cs — Class/method metadata
│ └── TestProjectOptions.cs — Generation configuration
└── Resources/
└── PsxTestGenerator.ico — Extension icon