我在查找有关如何单元测试.NET标准1.6类库(可从.NET Core项目引用)的最新文档时遇到问题。单元测试.NET标准1.6库
这里是我的project.json
看起来像我的图书馆:
{
"supports": {},
"dependencies": {
"Microsoft.NETCore.Portable.Compatibility": "1.0.1",
"NETStandard.Library": "1.6.0",
"Portable.BouncyCastle": "1.8.1.2"
},
"frameworks": {
"netstandard1.6": {}
}
}
现在剩下的任务就是要能够建立某种形式的一个项目,可以做单元测试。目标是使用xUnit,因为它似乎是.NET Core团队推动的。
我说干就干,创建一个具有project.json看起来像这样其他.NET移植的库项目:
{
"supports": {},
"dependencies": {
"Microsoft.NETCore.Portable.Compatibility": "1.0.1",
"NETStandard.Library": "1.6.0",
"xunit": "2.2.0-beta4-build3444",
"xunit.runner.visualstudio": "2.1.0"
},
"frameworks": {
"netstandard1.6": {
}
}
}
该项目中我的测试类是这样的:
using USB.EnterpriseAutomation.Security.DotNetCore;
using Xunit;
namespace Security.DotNetCore.Test
{
public class AesEncryptionHelperTests
{
[Fact]
public void AesEncryptDecrypt()
{
var input = "Hello world!";
var encrypted = AesEncryptionHelper.AesEncrypt(input);
var decrypted = AesEncryptionHelper.AesDecrypt(encrypted);
Assert.Equal(input, decrypted);
}
}
}
当我继续构建该项目时,测试浏览器没有看到我的任何测试。
我该如何着手创建一个能够测试这个库的单元测试?
有没有人在VS 2017 RTM中发现这一点?当我试图测试NetStandard库时,我的测试无法找到。我引用了xunit和xunit.runner.visualstudio的2.2版本。 –