您如何使用MiniProfiler从单元测试中查看配置文件信息

问题描述 投票:1回答:1

我正在尝试分析.Net Core 2.2库的各个部分。我决定使用单元测试,因为我要分析的许多领域都有单元测试。我正在尝试使用StackExchange的MiniProfiler,但是我没有在文档中看到任何有关如何查看分析结果的信息。

我在测试装置上创建了一个属性:公共MiniProfiler Profiler{得到;私人套装;}

并将其填充到灯具的构造函数中:

this.Profiler = MiniProfiler.StartNew("CRMODataDataSource Profiler");

然后调用我要分析的代码:

        using (Fixture.Profiler.Step("TestDefaultWithDynamic"))
        {
            testValue =
                (testEntity.HasPrimaryKey() == true)
                && testEntity.GetPrimaryKey().KeyValues.All(v =>
                {
                    if (null != v.Value)
                    {
                        return !CrmEntityFixture.ValueIsDefault((dynamic)v.Value);
                    }
                    return false;
                }
                );
        }
        Assert.True(testValue);

我使用以下方法安装了nuget软件包:安装包MiniProfiler.AspNetCore -IncludePrerelease

documentation显示了一个UI并进行了讨论,但从未提及如何启动UI。我已经搜索了输出文件夹,但没有找到任何类似于配置文件数据的文件。

谢谢

unit-testing mvc-mini-profiler
1个回答
0
投票

单元测试没有任何Web ui,相反,其行为几乎与控制台相同。签出此页:https://miniprofiler.com/dotnet/ConsoleDotNetCore

// Default configuration usually works for most, but override, you can call:
// MiniProfiler.Configure(new MiniProfilerOptions { ... });

var profiler = MiniProfiler.StartNew("My Profiler Name");
using (profiler.Step("Main Work"))
{
    // Do some work...
}

Console.WriteLine(profiler.RenderPlainText());
// or for the active profiler:
Console.WriteLine(MiniProfiler.Current.RenderPlainText());
© www.soinside.com 2019 - 2024. All rights reserved.