mstest

Data Driven MSTest: DataRow is always null

老子叫甜甜 提交于 2020-01-04 04:19:09
问题 I am having a problem using Visual Studio data driven testing. I have tried to deconstruct this to the simplest example. I am using Visual Studio 2012. I create a new unit test project. I am referencing system data. My code looks like this: namespace UnitTestProject1 { [TestClass] public class UnitTest1 { [DeploymentItem(@"OrderService.csv")] [DataSource("Microsoft.VisualStudio.TestTools.DataSource.CSV", "OrderService.csv", "OrderService#csv", DataAccessMethod.Sequential)] [TestMethod] public

Resharper 7 on VS2012 ignores assembly redirect in app.config

左心房为你撑大大i 提交于 2020-01-03 19:33:11
问题 We use moq and AutoMoq with mstest, and since upgrading to VS2012 and ReSharper 7, we the tests run fine with mstest, but fail when using the R# unit test runner with: Test method [...] threw exception: System.IO.FileLoadException: Could not load file or assembly 'Moq, Version=3.1.416.3, Culture=neutral, PublicKeyToken=69f491c39445e920' or one of its dependencies. The located assembly's manifest definition does not match the assembly reference. (Exception from HRESULT: 0x80131040) AutoMoq is

How to replace Middleware in integration tests project

旧城冷巷雨未停 提交于 2020-01-03 08:38:14
问题 I have startup cs where I register AuthenticationMiddleware like this: public class Startup { public void Configure(IApplicationBuilder app, IHostingEnvironment env) { ... AddAuthentication(app); app.UseMvcWithDefaultRoute(); app.UseStaticFiles(); } protected virtual void AddAuthentication(IApplicationBuilder app) { app.UseAuthentication(); } } and I test it using: WebApplicationFactory<Startup>().CreateClient(); Question: I would like to replace app.UseAuthentication(); with app

How to stop MsTest tests execution on first failure?

半世苍凉 提交于 2020-01-03 07:01:06
问题 We are running nightly builds which at the end run all of our UnitTest using the MsTest framework. We must have 100% pass rate, so if one fails there is no point running the others; hence we will like to stop the execution on the first failed test. Is there anyway we can do achieve it? 回答1: Are you really sure you want to throw away test results? Say somebody has a bad day and introduces multiple bugs A, B, and C into your code. You might only find out about A on Monday, so you fix that, and

Why does Microsoft.VisualStudio.TestTools.UnitTesting.Assert.Equals() exist?

ぐ巨炮叔叔 提交于 2020-01-03 06:50:12
问题 Description for Assert.Equals() from the MSDN Documentation: Do not use this method. That's it, the full explanation. Uh.. ok, but then ... why is it there? Is it a deprecated method from an earlier version of the framework? Something that's supposed to be used only by other Microsoft Assemblies? It just makes me want to use it all the more knowing I'm not supposed to. ;-) Does anyone know? 回答1: .Equals is inherited from object. It's listed as "Do not use this method" so users won't confuse

How do I test an abstract class's protected abstract method?

隐身守侯 提交于 2020-01-02 07:23:23
问题 I've been working on the best way to test an abstract class named TabsActionFilter . I've guranteed that classes that inherit from TabsActionFilter will have a method called GetCustomer . In practice this design seems to work well. Where I've had some issues is figuring out how to test the OnActionExecuted method of the base class. This method relies upon the implementation of the the protected abstract GetCustomer method. I've tried mocking the class using Rhino Mocks but can't seem to mock

Correct method for testing for an exception using Moq and MSTest

六眼飞鱼酱① 提交于 2020-01-02 06:33:53
问题 A little confusion as to the behaviour of Moq with MsTest. Edit: This is not a question of "How do I test?" or "How do I assert?", this is a scratch pad to see how MoQ works so don't focus on the exception type etc. I think a better question may be => "Does Moq Throws<> behave similar to MsTest ExpectedExceptionAttribute?" That is, they're expecting an exception in the test or the SUT? I'd like to know just how MoQ "Throws" works when used with MsTest. Is it better to not use the MsTest

How to test Ok() result using MStest in ASP.NET Core project

我的梦境 提交于 2020-01-02 04:34:07
问题 I'm using MStest for testing my controllers. I want to test this action: [HttpGet(Name = "GetGroups")] public async Task<IActionResult> Get() { var groups = await _unitOfWork.Repository<Groupe>().GetAllAsync(); var groupsDto = Mapper.Map<IEnumerable<GroupDto>>(groups); if (groupsDto.Count() == 0) { return NotFound(); } return Ok(groupsDto); } One of the test for this action looks like that: [TestMethod] public async Task Group_Get_Should_Return

How do I exclude service references from code coverage using the runsettings file in Visual Studio 2012?

人盡茶涼 提交于 2020-01-02 00:58:31
问题 I'm using a custom runsettings file to control what projects are inspected for code coverage. I used the default template provided by Microsoft and have so far been able to exclude the items I want with no issues. My next action is to exclude from code coverage the auto-generated web proxy classes that are created by Visual Studio when you add a service reference. This seemed something that should work with the default runsettings template since it has a section that looks like this:

Using AsConfigured and still be able to get UnitTest results in TFS

回眸只為那壹抹淺笑 提交于 2020-01-01 08:47:08
问题 So I am running into an issue when I go to build my projects using tfs build controller using the Output location "AsConfigred" it will not detect my unit tests. Let me give a little info on my setup. TFS 2013 Update 2, Default Process Template Here is a few screenshots that can hopefully help fill in what I can't in typing. I am copying my build out to a file share on our network so that we can use other utilities use the output. I don't want to use "PerProject" or "SingleFolder" because