我创建了一个带有 .Net 5 目标框架和一个测试类的新 XUnit 测试项目
public class SomeTests
{
private readonly ITestOutputHelper output;
public SomeTests(ITestOutputHelper output)
{
this.output = output;
DotMemoryUnitTestOutput.SetOutputMethod(output.WriteLine);
}
[Fact]
[DotMemoryUnit(CollectAllocations = true)]
public void SomeTest()
{
var beforeTestMethodPoint = dotMemory.Check();
var allocatedArray = new string[10];
dotMemory.Check(afterTestMethodPoint => Assert.True(afterTestMethodPoint.GetTrafficFrom(beforeTestMethodPoint).AllocatedMemory.SizeInBytes == 0));
}
}
安装的 NuGet 包是 JetBrains.DotMemoryUnit 3.1.20200127.214830
运行测试后(在 dotMemory Unit 下运行),将创建以下输出
Xunit.Sdk.TrueException
Assert.True() Failure
Expected: True
Actual: False
at TestsDotMemory.SomeTests.<>c__DisplayClass2_0.<SomeTest>b__0(Memory afterTestMethodPoint) in SomeTests.cs:line 25
at JetBrains.dotMemoryUnit.dotMemory.Check(Action`1 check)
at TestsDotMemory.SomeTests.SomeTest() in SomeTests.cs:line 25
[dotMemory Unit]: The workspace is saved to "file:///C:/Users/username/AppData/Local/Temp/dotMemoryUnitWorkspace/Run-2021-03-06T10-15-06.288/SomeTest.2021-03-06T10-15-11.629.dmw". (File size: 9 MB)
当我单击带有 .dmw 文件的链接时,dotmemory 应用程序已打开
当前应用程序版本和许可信息
JetBrains dotMemory 2020.3.3 Build 203.0.20210217.101844 built on 2021-02-17
dotMemory 2020.3.20210217.101844
dotMemory 2020.3.3 free trial period is running. 2 days left.
并出现对话窗口
The workspace you are trying to open is incompatible with the current dotMemory version. Do you want to open the workspace in a compatible portable dotMemory version?
如果我选择是,则会打开 dotMemory 2019.1.3,并显示有关许可证信息的对话框已结束(我的许可证仅适用于 2020.3)
那么为什么 dotMemory 2020.3.3 不支持 .dmw 文件呢?