Reputation: 12053
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 :)
Is there any possibility to have the same feature like tests with standard signature? Maybe there is any VS extension?
Upvotes: 2
Views: 815
Reputation: 436
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);
}
Upvotes: 1