A sandbox for smoke testing
var httpClient = Sanji.GetService("SUT").CreateHttpClient();
var response = await httpClient.GetAsync("/books");
Sanji is a sandbox for smoke testing. It will run your servies in processes and provide a friendly API to access in test cases.
As sanji is only a sandbox for testing, we still need test runner like MSTest to run our test cases.
We need a appsettings.json file to specify servies we want to test.
{
"Services": [
{
"Name": "SampleASP1",
"Executable": "SampleASP1.exe",
"Port": 5000
}
]
}
We have to start all services before test starts.
[TestClass]
public class AssemblyInit
{
[AssemblyInitialize]
public static void AssemblyInitialize(TestContext context)
{
Sanji.Start();
}
[AssemblyCleanup]
public static void AssemblyCleanup()
{
Sanji.Stop();
}
}
We can easily send HTTP request to our services under test with Sanji.
var httpClient = Sanji.GetService("SUT").CreateHttpClient();
var response = await httpClient.GetAsync("/books");