Skip to content

A sandbox for smoke testing 🎁

License

Notifications You must be signed in to change notification settings

callmewhy/sanji

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

10 Commits
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

Sanji

Build NuGet

A sandbox for smoke testing

var httpClient = Sanji.GetService("SUT").CreateHttpClient();
var response = await httpClient.GetAsync("/books");

What?

Sanji is a sandbox for smoke testing. It will run your servies in processes and provide a friendly API to access in test cases.

How?

Step1: Create your MSTest project

As sanji is only a sandbox for testing, we still need test runner like MSTest to run our test cases.

Step2: Add appsettings.json

We need a appsettings.json file to specify servies we want to test.

{
    "Services": [
        {
            "Name": "SampleASP1",
            "Executable": "SampleASP1.exe",
            "Port": 5000
        }
    ]
}

Step3: Add AssemblyInit.cs

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();
    }
}

Step4: Write tests!

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");