我已经使用.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单元下运行)之后,将创建以下输出
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)
那么为什么.dmw文件不支持dotMemory 2020.3.3呢?
发布于 2021-03-06 20:40:45
为了给用户提供新的功能,.dmw文件格式经常被改变。不幸的是,dotMemory单位生产了一个旧格式的工作区,因为新版本已经有几年没有发布了。据我所知,您没有dotMemory 2020.3的许可证,您使用的是试用期。而dotMemory 2019.1.3的试用期在您的机器上已经结束。任何版本的dotMemory的付费许可肯定涵盖了所有以前的版本。
https://stackoverflow.com/questions/66503519
复制相似问题