UWP 应用程序中的 MSTest 代码覆盖率 returns 为空
MSTest code coverage returns empty in UWP Application
我的 UWP 应用程序中的 MSTest 代码覆盖率有问题。
每次我尝试 运行 报道时,我都会得到这样的结果:
Empty results generated: No binaries were instrumented. Make sure the tests ran, required binaries were loaded, had matching symbol files, and were not excluded through custom settings. For more information see https://go.microsoft.com/fwlink/?LinkID=253731
我已经按照上面 link 中所有不同的故障排除方法进行了操作。但他们似乎没有解决它。我不知道是什么原因造成的,但这里有一些与我的环境相关的信息。
我的测试项目的参考资料:
我引用的 *.pdb 文件存在于我的测试项目的构建目录中。
[TestClass]
public class UnitModelTests
{
[DataTestMethod]
#region Metric
[DataRow(LengthMetric.MM, "1mm", UnitType.Metric)]
[DataRow(LengthMetric.CM - LengthMetric.MM, "9mm", UnitType.Metric)]
[DataRow(LengthMetric.CM, "1cm", UnitType.Metric)]
[DataRow(LengthMetric.DM - LengthMetric.CM, "9cm", UnitType.Metric)]
[DataRow(LengthMetric.DM, "1dm", UnitType.Metric)]
[DataRow(LengthMetric.M - LengthMetric.DM, "9dm", UnitType.Metric)]
[DataRow(LengthMetric.M, "1m", UnitType.Metric)]
[DataRow(LengthMetric.KM - LengthMetric.M, "999m", UnitType.Metric)]
[DataRow(LengthMetric.KM, "1km", UnitType.Metric)]
[DataRow(LengthMetric.KM * 100, "100km", UnitType.Metric)]
#endregion
#region Imperial
[DataRow(LengthImperial.Inch, "1 inch", UnitType.Imperial)]
[DataRow(LengthImperial.Feet, "1 feet", UnitType.Imperial)]
[DataRow(LengthImperial.Yard, "1 yard", UnitType.Imperial)]
[DataRow(LengthImperial.Chain, "1 chain", UnitType.Imperial)]
[DataRow(LengthImperial.Furlong, "1 furlong", UnitType.Imperial)]
[DataRow(LengthImperial.Mile, "1 mile", UnitType.Imperial)]
[DataRow(LengthImperial.League, "1 league", UnitType.Imperial)]
#endregion
public void LengthToStringTest(double startLength, string expected, UnitType unitType)
{
var length = new Length(startLength);
Assert.AreEqual(expected, length.UnitToString(unitType));
}
[DataTestMethod]
#region Metric
[DataRow(VolumeMetric.MM, "1mm^3", UnitType.Metric)]
[DataRow(VolumeMetric.MM * 9, "9mm^3", UnitType.Metric)]
[DataRow(VolumeMetric.CM, "1cm^3", UnitType.Metric)]
[DataRow(VolumeMetric.CM * 9, "9cm^3", UnitType.Metric)]
[DataRow(VolumeMetric.DM, "1dm^3", UnitType.Metric)]
[DataRow(VolumeMetric.DM * 9, "9dm^3", UnitType.Metric)]
[DataRow(VolumeMetric.M, "1m^3", UnitType.Metric)]
[DataRow(VolumeMetric.M * 999, "999m^3", UnitType.Metric)]
[DataRow(VolumeMetric.KM, "1km^3", UnitType.Metric)]
[DataRow(VolumeMetric.KM * 100, "100km^3", UnitType.Metric)]
#endregion
#region Imperial
[DataRow(VolumeImperial.FluidOunce, "1 Fluid ounce", UnitType.Imperial)]
[DataRow(VolumeImperial.Gill, "1 Gill", UnitType.Imperial)]
[DataRow(VolumeImperial.Pint, "1 Pint", UnitType.Imperial)]
[DataRow(VolumeImperial.Quart, "1 Quart", UnitType.Imperial)]
[DataRow(VolumeImperial.Gallon, "1 Gallon", UnitType.Imperial)]
#endregion
public void VolumeToStringTest(double startVolume, string expected, UnitType unitType)
{
var volume = new Volume(startVolume);
Assert.AreEqual(expected, volume.UnitToString(unitType));
}
}
测试结果:
此处显示的所有测试 return 均成功。
构建配置:
MSTest项目的NuGet包:
如果需要更多信息,请发表评论。
UWP MSTest 实现目前不支持代码覆盖率。 Here 是一个 link 到谈论它的博客。解决方法是将 UWP Class Libary
更改为 .NET Standard Class Libary
。然后将 UWP MSTest project
更改为 .NET Core
变体。通过测试资源管理器更改此和 运行 代码覆盖率后,您将获得所需的结果。
为了更好地解释这个问题,你可以访问这个讨论它的网站。 https://www.redgreencode.com/unit-testing-uwp-apps/
我的 UWP 应用程序中的 MSTest 代码覆盖率有问题。
每次我尝试 运行 报道时,我都会得到这样的结果:
Empty results generated: No binaries were instrumented. Make sure the tests ran, required binaries were loaded, had matching symbol files, and were not excluded through custom settings. For more information see https://go.microsoft.com/fwlink/?LinkID=253731
我已经按照上面 link 中所有不同的故障排除方法进行了操作。但他们似乎没有解决它。我不知道是什么原因造成的,但这里有一些与我的环境相关的信息。
我的测试项目的参考资料:
我引用的 *.pdb 文件存在于我的测试项目的构建目录中。
[TestClass]
public class UnitModelTests
{
[DataTestMethod]
#region Metric
[DataRow(LengthMetric.MM, "1mm", UnitType.Metric)]
[DataRow(LengthMetric.CM - LengthMetric.MM, "9mm", UnitType.Metric)]
[DataRow(LengthMetric.CM, "1cm", UnitType.Metric)]
[DataRow(LengthMetric.DM - LengthMetric.CM, "9cm", UnitType.Metric)]
[DataRow(LengthMetric.DM, "1dm", UnitType.Metric)]
[DataRow(LengthMetric.M - LengthMetric.DM, "9dm", UnitType.Metric)]
[DataRow(LengthMetric.M, "1m", UnitType.Metric)]
[DataRow(LengthMetric.KM - LengthMetric.M, "999m", UnitType.Metric)]
[DataRow(LengthMetric.KM, "1km", UnitType.Metric)]
[DataRow(LengthMetric.KM * 100, "100km", UnitType.Metric)]
#endregion
#region Imperial
[DataRow(LengthImperial.Inch, "1 inch", UnitType.Imperial)]
[DataRow(LengthImperial.Feet, "1 feet", UnitType.Imperial)]
[DataRow(LengthImperial.Yard, "1 yard", UnitType.Imperial)]
[DataRow(LengthImperial.Chain, "1 chain", UnitType.Imperial)]
[DataRow(LengthImperial.Furlong, "1 furlong", UnitType.Imperial)]
[DataRow(LengthImperial.Mile, "1 mile", UnitType.Imperial)]
[DataRow(LengthImperial.League, "1 league", UnitType.Imperial)]
#endregion
public void LengthToStringTest(double startLength, string expected, UnitType unitType)
{
var length = new Length(startLength);
Assert.AreEqual(expected, length.UnitToString(unitType));
}
[DataTestMethod]
#region Metric
[DataRow(VolumeMetric.MM, "1mm^3", UnitType.Metric)]
[DataRow(VolumeMetric.MM * 9, "9mm^3", UnitType.Metric)]
[DataRow(VolumeMetric.CM, "1cm^3", UnitType.Metric)]
[DataRow(VolumeMetric.CM * 9, "9cm^3", UnitType.Metric)]
[DataRow(VolumeMetric.DM, "1dm^3", UnitType.Metric)]
[DataRow(VolumeMetric.DM * 9, "9dm^3", UnitType.Metric)]
[DataRow(VolumeMetric.M, "1m^3", UnitType.Metric)]
[DataRow(VolumeMetric.M * 999, "999m^3", UnitType.Metric)]
[DataRow(VolumeMetric.KM, "1km^3", UnitType.Metric)]
[DataRow(VolumeMetric.KM * 100, "100km^3", UnitType.Metric)]
#endregion
#region Imperial
[DataRow(VolumeImperial.FluidOunce, "1 Fluid ounce", UnitType.Imperial)]
[DataRow(VolumeImperial.Gill, "1 Gill", UnitType.Imperial)]
[DataRow(VolumeImperial.Pint, "1 Pint", UnitType.Imperial)]
[DataRow(VolumeImperial.Quart, "1 Quart", UnitType.Imperial)]
[DataRow(VolumeImperial.Gallon, "1 Gallon", UnitType.Imperial)]
#endregion
public void VolumeToStringTest(double startVolume, string expected, UnitType unitType)
{
var volume = new Volume(startVolume);
Assert.AreEqual(expected, volume.UnitToString(unitType));
}
}
测试结果: 此处显示的所有测试 return 均成功。
构建配置:
MSTest项目的NuGet包:
如果需要更多信息,请发表评论。
UWP MSTest 实现目前不支持代码覆盖率。 Here 是一个 link 到谈论它的博客。解决方法是将 UWP Class Libary
更改为 .NET Standard Class Libary
。然后将 UWP MSTest project
更改为 .NET Core
变体。通过测试资源管理器更改此和 运行 代码覆盖率后,您将获得所需的结果。
为了更好地解释这个问题,你可以访问这个讨论它的网站。 https://www.redgreencode.com/unit-testing-uwp-apps/