Local Testing 101
  • 30 Nov 2022
  • 1 Minute to read
  • Contributors
  • Comment
  • Dark
  • PDF

Local Testing 101

  • Comment
  • Dark
  • PDF

Article summary

In the local unit testing you are using IPB.LogicApp.Standard.Testing.Local.
You will use the WorkflowTestHost class in the framework which you will setup by pointing it to a folder containing your workflow definitions and the configuration files and then you run the test host which will behind the scenes spin up func.exe running your workflow and it will then allow you to test it as shown below.

var workflowToTestName = "Echo";
var workflowTestHostBuilder = new WorkflowTestHostBuilder();
using (var workflowTestHost = workflowTestHostBuilder.LoadAndBuild())
    //Add your code to test the workflow here

You will then setup the LogicAppTestManager to act as a client to call your workflow.

//Create the test manager to act as the client for testing the logic app
var logicAppTestManager = new LogicAppTestManager(new LogicAppTestManagerArgs
    WorkflowName = workflowToTestName

You can then trigger your workflow like below (assuming it has an HTTP trigger)

var content = new StringContent("{}", Encoding.UTF8, "application/json");
var response = logicAppTestManager.TriggerLogicAppWithPost(content);

You can then load the workflow run history and make assertions such as if the trigger was successful


var triggerStatus = logicAppTestManager.GetTriggerStatus();
Assert.AreEqual(triggerStatus, TriggerStatus.Succeeded);

You can also test the results of actions

var actionStatus = logicAppTestManager.GetActionStatus("Response");
Assert.AreEqual(actionStatus, ActionStatus.Succeeded);

The aim is to assert the expected actions for the result you expect which allows you to validate the workflow ran as expected for the scenario you want


The below link is to one of the tests within the github repo where it will give an example of using the local testing


Was this article helpful?