[英]Failing in Code coverage Test with a simple class constructor
I have a class: 我有一堂课:
public class SourceServerProvider : ISourceServerProvider
{
private readonly ISourceServer _sourceServer;
public SourceServerProvider()
:this(new SourceServer())
{ }
public SourceServerProvider(ISourceServer sourceServer)
{
_sourceServer = sourceServer;
}
}
MS code coverage test complaints to this block: MS代码覆盖率测试对该块的投诉:
public SourceServerProvider()
:this(new SourceServer())
{ }
I don't know how to write a unit test for above block. 我不知道如何为上述代码块编写单元测试。 Please advise..
请指教..
I just tested it with the followig code: 我只是用以下代码测试了它:
public class SourceServerProvider : ISourceServerProvider
{
private readonly ISourceServer _sourceServer;
public SourceServerProvider()
: this(new SourceServer())
{ }
public SourceServerProvider(ISourceServer sourceServer)
{
_sourceServer = sourceServer;
}
}
public interface ISourceServer
{
}
public class SourceServer : ISourceServer
{
}
public interface ISourceServerProvider
{
}
and wrote this test 并写了这个测试
public class Class1
{
[Test]
public void test()
{
var a = new SourceServerProvider();
}
}
Code Coverage says it is fully covered: 代码覆盖率表示已完全覆盖:
so please add the result you are getting or create asimple test that call the default ctor 所以请添加您得到的结果或创建调用默认ctor的asimple测试
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.