@page "/MyTests/TestDocsAsserts"
@inherits IcuBlazor.IcuTestSuite
@code {
public void TestSimpleChecks()
{
Check().True(2 < 3, "a true test");
Check().False(2 == 3, "a false test");
Check().Equal(6*9, 42, "What's the question?");
}
async Task TestAsyncMethod()
{
var t0 = DateTime.Now;
await Task.Delay(500);
var dt = (DateTime.Now - t0).TotalMilliseconds;
Check().True(dt>500, $"async test waited {dt} ms");
}
}
Many traditional testing frameworks already exist.
They were designed for testing with either .NET, JavaScript, or thru browser automation.
But Blazor is a merger of .NET & Web technologies.
So better tools are possible and necessary.
IcuBlazor is a .NET testing tool, a JS testing tool,
and a web automation tool all rolled into a simple API.
Also, IcuBlazor provides additional blazor dev tools to help development.
.NET Testing XUnit, NUnit, ... |
JS Testing Jest, QUnit, ... |
Web Automation Selenium, Playwright, ... |
Blazor Testing IcuBlazor | |
---|---|---|---|---|
Assertion Tests | ||||
.NET Code Access | ||||
UI Automation | ||||
UI Diffing Tests | ||||
Text Diffing Tests | ||||
Blazor Specific Tools | ||||
Hot Reload 🔥 |
What if assertion tests were more than pass/fail operations? What if asserts produced Blazor components? This would allow us to do some powerful things. For example, we could produce visual diffs and enable interactive testing.