Skip to main content

Run and Test

In the previous step, we created a simple plugin, registered a metric, and updated the metric's value.
Now, let's run the plugin to make sure it works as expected.

Modifying Program.cs​

Instead of installing the plugin in MoBro every time we want to test it, the SDK provides a convenient utility called MoBroPluginBuilder. It creates and runs the plugin locally, just like MoBro would.

Replace the content of the Program.cs file with the following:

Plugin.Example/Program.cs
using MoBro.Plugin.SDK;

// Create and start the plugin to test it locally
using var plugin = MoBroPluginBuilder
.Create<Plugin.Example.Plugin>()
.Build();

// Keep the plugin running until enter is pressed
Console.ReadLine();

Build and Run​

Since this is a standard .NET console application, you can run it directly from your IDE (including the debugger).
Alternatively, run the following command in the project directory:

dotnet run

Output​

Once the plugin is built and started, you should see the following output:

PS C:\dev\Plugin.Example> dotnet run
16:23:03.959 [INF] Creating new plugin instance
16:23:03.965 [INF] Invoking 'init' function on plugin
16:23:03.986 [INF] Registered Metric: first_metric
16:23:03.990 [DBG] Value of metric first_metric updated to: Hello World

From the logs, you can see that:

  1. A new instance of the plugin was created.
  2. The Init() function was called.
  3. The first_metric metric was registered.
  4. The value of first_metric was updated to Hello World.

Congratulations!​

You've successfully created and run your first plugin! 🎉

See it in MoBro

Can't wait to see the metric in MoBro? With MoBro running, install the plugin straight from the project directory using the CLI:

mobro install .

Then open the Metric Explorer in MoBro. Publish and Install covers this step in detail.

Currently, the plugin provides a single metric whose value never changes.
In the next section, we will:

  • Expand the functionality by updating metrics periodically.
  • Add a setting to let users customize the plugin.