简体   繁体   中英

C# Unit-test not running when constructor class exist

This is a simple unit Test class with test method called 'TestMethod1()' . when i write ctor inside it, unit test doesn't run anymore. but without ctor test case work as well.

public class OrderTests 
{
    public OrderTests (int value)
    {  }
    public void TestMethod1()
    {
       Xunit.Assert.Equal(7, 7);
    }
}

Thanks a lot.

You need to add the Fact attribute to the test so that is recognised as a test and not just a method eg:

[Fact]
public void TestMethod1()
{
   Xunit.Assert.Equal(7, 7);
}

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM