With IcuBlazor you can define basic unit tests using asserts like True(), False(), Equal() etc...
The results are displayed in the live <IcuTestViewer> component below.
Try clicking on the toolbar menu and changing the layout to "Outcome view".

 

The above output was generated from the code below. By convention, unit tests are just methods that start with "test" and are defined in a subclass of IcuTestSuite. You can opt to create tests explicitly with any convention you like.

@inherits IcuBlazor.IcuTestSuite

@code {

    public void Test_SimpleChecks()
    {
        Check().True(2 < 3, "a true test");
        Check().False(2 == 3, "a false test");
        Check().Equal(6*9, 42, "What's the question?");
    }

    void Test_Hello_World()
    {
        var (a, b) = ("Hello", "World");
        Check().Equal(a + b, "Hello World", "Not quite right");
        Check().True(2 < 3, "show asserts even when previous ones failed");
    }

    async Task Test_async_method()
    {
        var t0 = DateTime.Now;
        await Task.Delay(500);
        var dt = (DateTime.Now - t0).TotalMilliseconds;

        // Surprise! Sometimes dt<500 :o
        Check().True(500 < dt && dt < 550, $"async test waited {dt} ms");
    }
}


An error has occurred. This application may no longer respond until reloaded. Reload 🗙