SkyWeb Auto Test Generator
SkyWeb Auto Test Generator v2.0 is an intelligent Visual Studio extension that uses Roslyn analysis, NUnit, and Moq to automatically generate practical unit tests for your C# services and classes.
Generate a complete NUnit + Moq test fixture from a service, or let the extension analyze your existing test class and generate only the missing tests.
✨ What's New in v2.0
- 🧠 Roslyn-powered C# analysis for understanding classes, methods, constructors, dependencies, and method calls
- 🧩 Automatic dependency mocking with Moq
- 🧪 Complete NUnit test class generation with
[TestFixture], [SetUp], Arrange/Act/Assert, assertions, and Verify
- ⚡ Async support with
ReturnsAsync and async NUnit tests
- 🔄 Void method support with automatic Moq verification
- 🌿 Branch and exception test generation for detectable scenarios
- 🖱️ Cursor-based generation — place your cursor inside a service class without selecting the entire class
- 🧪 Generate Missing Tests by analyzing an existing test class against its service
- 🎨 Existing test style preservation — generated tests can follow the existing SUT names, mock names, assertion style, and formatting conventions
- 🚫 Duplicate prevention — existing covered methods are not regenerated
- 🔙 Legacy fallback — existing test-generation functionality remains available for unsupported selections
🚀 Generate Unit Tests
Place your cursor inside a service class or select the class and choose:
SkyWeb: Generate Unit Tests
For example:
public class OrderService
{
private readonly IOrderRepo _orderRepo;
public OrderService(IOrderRepo orderRepo)
{
_orderRepo = orderRepo;
}
public List<Order> GetOrder(int id)
{
return _orderRepo.GetOrder(id);
}
}
The extension can generate a complete test fixture with:
[TestFixture]
public class OrderServiceTests
{
private Mock<IOrderRepo> _orderRepoMock;
private OrderService _orderService;
[SetUp]
public void Setup()
{
_orderRepoMock = new Mock<IOrderRepo>();
_orderService = new OrderService(_orderRepoMock.Object);
}
[Test]
public void GetOrder_ShouldReturnOrders()
{
// Arrange
int id = 1;
// Mock repository
// Act
var result = _orderService.GetOrder(id);
// Assert
Assert.That(result, Is.Not.Null);
_orderRepoMock.Verify(
x => x.GetOrder(id),
Times.Once);
}
}
🧩 Generate Missing Tests
Already have a test class with most of your tests written?
Open your existing test class and choose:
SkyWeb: Generate Missing Tests
The extension compares the public methods in your service with the methods already covered by your tests.
For example:
Service methods: 11
Already covered: 8
Missing: 3
It generates tests only for the uncovered methods — without replacing or duplicating your existing tests.
It also analyzes existing test conventions, including:
- SUT field naming
- Mock field naming
- NUnit assertion style
- Arrange/Act/Assert formatting
- Moq setup conventions
This makes generated tests fit more naturally into an existing test project.
🧪 NUnit + Moq Support
The generator can automatically create:
Mock<T> dependencies
- Constructor injection
.Setup(...)
.Returns(...)
.ReturnsAsync(...)
.Verify(...)
Times.Once
- NUnit assertions
- Exception assertions
- Async test methods
- Void method verification
📋 Existing Features
The original generator functionality is still supported:
- Method test generation
- Void and return-type methods
- Property getter/setter tests
- Null parameter scenarios
- Collection/empty-result scenarios
- Conditional/branch scenarios
- Clipboard-based generated code
- Legacy fallback for unsupported code selections
🛠️ Requirements
- Visual Studio 2022 (v17.0 or newer)
- .NET Framework 4.7.2 or higher
- NUnit in your test project
- Moq for dependency-mocking scenarios
⚠️ Current Limitations
- Analysis currently uses Roslyn Syntax Trees rather than a full SemanticModel.
- Complex multi-file/partial-class scenarios may require additional context.
- Complex DTO/entity test data may contain conservative
TODO placeholders.
- Missing-test detection uses syntax-based analysis of SUT method invocations.
- Generated tests may require minor manual adjustment for highly project-specific types or behavior.
👨💻 Developer
Surya Pratap Singh
🚀 Version 2.0
From generating individual NUnit test methods to intelligently generating and maintaining NUnit + Moq unit tests for your existing C# services.