简体   繁体   中英

Unit tests failing to run on TestClass defined class

I have a test class:

[TestClass]
class DocumentStoreProviderTests : TestBase
{
    [TestMethod, TestCategory(Unit)]
    public void DocumentProvider_AssertEntityToCreateIsValid_Fail_When_DocumentNameIsEmpty()
    {
        // arrange
        var scope = new DefaultScope();
        var invalidUpdateEntity = Builder<Dom.Document>
            .CreateNew()
            .With(x => x.Name, string.Empty)
            .Build();

        //act
        Action methodUnderTest = () => scope.InstanceUnderTest.AssertEntityToCreateIsValidAsync(invalidUpdateEntity).GetAwaiter().GetResult();

        //Assert
        methodUnderTest.ShouldThrow<BusinessValidationException>();
    }
}

However I am getting this when I try to run the tests:

========== Discover test finished: 1090 found (0:00:02.8716539) ==========
No tests found to run.

I am using resharper to run the unit tests and all of my other test files run fine.

What am I doing wrong and how do I fix it?

将类DocumentStoreProviderTests和TestBase设置为公共。

TestCategory ("Unit") should fix it. It matches a string that is the name of the category.

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