This package allows users to test their code against business requirements. Nosimus AI collects call graph for the specified class and entry point (method) and tests it against given business requirements using GPT.
- Install Nosimus AI package and CSharp code analysis packages
dotnet add package NosimusAI.TestSuite dotnet add package Microsoft.CodeAnalysis.CSharp dotnet add package Microsoft.CodeAnalysis.CSharp.Workspaces
- Add the following section to your configuration (either in appsettings.json or code config)
{ "Nosimus": { "OpenAiKey": "", "SolutionPath": "Full path to .sln file" } }
- Register Nosimus AI services
serviceCollection.AddNosimusAI(configuration);
- Use it in any test framework of your choice
1 Comment
timurishmuratov
So it does what the title says – essentially, it collects a call graph using Roslyn libraries and then passes it to GPT to verify that all business requirements are met. It acts as an additional safeguard for your code.
You can easily use it unit testing framework of your choice as following
[Test]
public async Task ShouldPassBusinessRequirement()
{
var testRunner = GlobalTestSetup.ServiceProvider!.GetRequiredService<TestRunner>();
var result = await testRunner.RunTest(
@"Must borrow the book.
Must ensure that book was not borrowed more than 30 days ago.
Must ensure that abonent did not borrow more than 3 books.",
typeof(Book), // Class (entry point)
"Borrow", // Method (entry point)
CancellationToken.None);
Assert.That(result.Passed, Is.EqualTo(true));
}
After you run TestRunner, it returns a result indicating whether your code meets the business requirements using GPT.
Also this package allows you to generate Gherkin tests given code. Uses call graph produced from entrypoint (class -> method) to generate tests cases.