mstest

How to set up LocalDb for unit tests in Visual Studio 2012 and Entity Framework 5

荒凉一梦 提交于 2019-11-28 16:58:02
问题 We have a Visual Studio 2012 ASP.NET MVC project using Entity Framework 5. There are some unit tests that depend on a database. Setting up the app.config file in the test project to use a central SQL Server database works fine. However, it would be much nicer to use a LocalDb, so that each developer has his/her own database when running the tests. Especially since we would like to have the tests set up to DropCreateDatabaseAlways when running. However, I can't get the setup to work. If I try

Is it possible to execute code once before all tests run?

北城余情 提交于 2019-11-28 16:55:37
Basically I would like to tell MSTest to execute a bit of code before launching into a series of test runs, essentially what I would like to do is the same thing as sticking some code in Main() . The reason I would like to do this is that I would like to do some logging with log4net during my integration test runs. I cannot just use the log4net.Config.XmlConfigurator assembly attribute since by the time it reads it in my test assembly it has already called LoggerManager . The documentation recommends configuring log4net explicitly at the code entry point - but where is that in my tests? I need

MSTest run fails because source assembly is not trusted

落爺英雄遲暮 提交于 2019-11-28 16:25:36
问题 I just added xUnit to our test project (for the Asserts, we're still using MSTest as the framework) and immediately the test runs refused to execute any of the tests. This is the error message: Failed to queue test run '{ .... }' Test run deployment issue: The location of the file or directory '...xUnit.dll' is not trusted. 回答1: It took me a few tries to find the answer in Google, so I'm putting it here in case anyone else runs into the same problem. A detailed description can be found at

Visual Studio 2013 MSTest vs NUnit

試著忘記壹切 提交于 2019-11-28 16:16:52
问题 My company is upgrading our Visual Studio 2012 to 2013 Premium. In the midst of this, we are also looking to start automating our tests using Visual Studio Team Services I have read a couple of MSTest vs nUnit posts and articles in the past but most of it compares the older version of MSTest. Also, nUnit had a lot of favourable reviews as compared to MSTest. My question is, considering Microsoft's commitment towards the ALM, Agile practices and all the new stuff they've added into VS2013

No Code Coverage Information for Tests Using Moles

家住魔仙堡 提交于 2019-11-28 14:48:02
I have been getting used to OpenCover over the past few days, and have I noticed that tests using Moles do not generate any Coverage information. I have created a small solution to isolate the problem, and have found that code coverage is generated only for tests that do not have the [HostType("Moles")] attribute. Reading around I have found this and this which seem to be NCover equivalents of my problem. They say that it is something to do with Moles running a profiler as well as the coverage tool, and that there is an environment variable CLRMONITOR_EXTERNAL_PROFILERS that can be set to

VS 2010 Test Runner error “The agent process was stopped while the test was running.”

|▌冷眼眸甩不掉的悲伤 提交于 2019-11-28 14:30:59
问题 In Visual Studio 2010, I have a number of unit tests. When I run multiple tests at one time using test lists, I sometimes reveive the following error for one or more of the tests: The agent process was stopped while the test was running. It is never the same test failing, and if I try to run the test again, it succeeds. I found this bug report on Connect, which seems to be the same problem, but it does not offer a solution. Has anyone else seen this behaviour ? How I can avoid it ? Edit I am

How to refresh UIMap object in CodedUI

China☆狼群 提交于 2019-11-28 11:21:52
问题 Can i refresh UIMap object ? Problem is I change the location of UI element on and I again try to get the AutomationElement at that time I get AutomationELment but its BoundingRectanle is infinity. So i am assuming that it is not refreshing the UIMap object. Can anyone please help me on this ? 回答1: In the UIMaps section of your test, you have probably something like: private MyTestUIMap uiMap; public MyTestUImap UIMap { get { if (this.uiMap == null) { this.uiMap = new MyTestUIMap(); } return

Visual Studio 2013 is unable to open the Test Window

喜夏-厌秋 提交于 2019-11-28 10:47:27
When I open Visual Studio 2013 and load my solution I'm greeted by an error message telling me the Test Window is unable to load. The composition produced a single composition error. The root cause is provided below. Review the CompositionException.Errors property for more detailed information. 1) Cannot compose part 'Microsoft.VisualStudio.TestWindow.Controller.TestsServiceInternal' because a cycle exists in the dependencies between the exports being composed. To break this cycle, consider changing some imports from constructor to property injection. Element: Microsoft.VisualStudio.TestWindow

Change Default MsTest Unit Test Wizard Template

旧时模样 提交于 2019-11-28 10:26:43
My team is using the unit test wizard, but has found the amount of cruft generated annoying. Is there anyway to modify this template? Thanks Yes, you can, on several levels: Project Template You can get rid of the "About Test Projects" and other files using the Options menu in Visual Studio. Go to Test Tools -> Test Project and unselect the options you don't want. If that is not enough, you can find the project template in a folder similar to this: C:\Program Files (x86)\Microsoft Visual Studio 9.0\Common7\IDE\ProjectTemplates\CSharp\Test\1033 Your path may differ slightly if you run on 32-bit

Interacting with multiple instances of an application in Coded UI

青春壹個敷衍的年華 提交于 2019-11-28 10:15:28
问题 The scenario that I am facing is that I am trying to write a single test which will use Coded UI to interact with multiple instances of the same application, in this case Microsoft Excel. In other words, there will be multiple Excel workbooks open in multiple windows, and I need to be able to direct Coded UI to interact with a specific instance programatically. I initially thought this type of instance management would be a function of the ApplicationUnderTest class, but it is not obvious how