2

I use Visual Studio 2015 Ultimate, I wrote some unit test (I use xUnit 2.1.0.3179, it allow for this signature):

public async Task MyTest()

instead of standard unit test signature

public void MyTest()

but these unit tests are not visible in Visual Studio (code lens) and in Test Explorer. Of course I rebuild solution without any error :)

enter image description here

Is there any possibility to have the same feature like tests with standard signature? Maybe there is any VS extension?

Jacek
  • 11,661
  • 23
  • 69
  • 123
  • Is this test running [in ASP.NET by any chance](http://stackoverflow.com/questions/31799380/xunit-async-tests-shows-up-as-external-in-vs2015)? – Scott Chamberlain Aug 03 '16 at 20:14
  • I thought that xUnit tests weren't able to access CodeLens at all, hence no mention of them in CodeLens... or am I mistaken? – netchkin Aug 23 '16 at 11:51

1 Answers1

1

I'm pretty sure that you might've found a solution for this already, but I found your question while I was trying to fix my async unit test. (Note: I'm using the latest Visual Studio 2015 Update 3).

   [TestMethod]
    public async Task GetVendors_ByRegionId_ReturnFilteredVendors()
    {
        // Arrange
        var optionsBuilder = new DbContextOptionsBuilder();
        optionsBuilder.UseSqlServer("Server=server12345;Database=DB789;Trusted_Connection=True;MultipleActiveResultSets=true");
        var ctx = new ApplicationDbContext(optionsBuilder.Options);
        ILoggerFactory logFac = new LoggerFactory();
        ILogger<VendorRepository> loggerRepository = new Logger<VendorRepository>(logFac);
        IVendorRepository vendRepo = new VendorRepository(ctx, loggerRepository);

        // Act
        Task<List<Vendor>> resultTask = vendRepo.GetVendors(1);
        IList<Vendor> vendorList = await resultTask;

        // Assert
        Assert.IsNotNull(vendorList);
        Assert.IsTrue(vendorList.Count > 10);
    }
minerva
  • 436
  • 6
  • 16