mstest

MSTest Test Context Exception Handling

£可爱£侵袭症+ 提交于 2019-12-18 16:17:27
问题 Is there a way that I can get to the exception that was handled by the MSTest framework using the TestContext or some other method on a base test class? If an unhandled exception occurs in one of my tests, I'd like to spin through all the items in the exception.Data dictionary and display them to the test result to help me figure out why the test failed (we usually add data to the exception to help us debug in the production env, so I'd like to do the same for testing). Note: I am not testing

Data driven tests generated in ClassInitialize: no longer working in Visual Studio 2012

心不动则不痛 提交于 2019-12-18 12:08:02
问题 I have upgraded from Visual Studio 2010 to Visual Studio 2012. In my unit test project, I have a [ClassInitialize] method which generates a CSV file which I then feed into a data-driven [TestMethod] using [DataSource] connected to the CSV. This works great in Visual Studio 2010. I cannot get this to work in Visual Studio 2012. It seems that in VS2012 the MS test runner requires the file connected to the [DataSource] to already exist otherwise none of the tests will run. If I create the CSV

Understanding the MSTest TestContext

吃可爱长大的小学妹 提交于 2019-12-18 11:44:41
问题 Using MSTest, I needed to obtain the name of the current test from within the [TestInitialize] method. You can get this from the TestContext.TestName property. I found an unexpected difference in behaviour between a static TestContext that is passed in to the [ClassInitialize] method and one that is declared as a public property (and gets set by the test runner). Consider the following code: using System; using Microsoft.VisualStudio.TestTools.UnitTesting; namespace TestContext.Tests {

Are multiple asserts bad in a unit test? Even if chaining?

六月ゝ 毕业季﹏ 提交于 2019-12-18 10:33:11
问题 Is there anything wrong with checking so many things in this unit test?: ActualModel = ActualResult.AssertViewRendered() // check 1 .ForView("Index") // check 2 .WithViewData<List<Page>>(); // check 3 CollectionAssert.AreEqual(Expected, ActualModel); // check 4 The primary goals of this test are to verify the right view is returned (check 2) and it contains the right data (check 4). Would I gain anything by splitting this into multiple tests? I'm all about doing things right, but I'm not

Couldn't run my test using Microsoft Test Manager

谁都会走 提交于 2019-12-18 09:37:32
问题 When I'm running the test in Microsoft Test Manager I get an error: The build directory of the test run either does not exist or access permission is required. What does it mean? Where can I check build directory? 回答1: I suppose you are running automated tests. If you are running automated test in Microsoft Test Manageg (MTM) you have Test Case(s) automated by your test implementation. So MTM need to know where is the drop location of the build building your tests. That means you have to:

MsTest DeploymentItem OutputDirectory in testsettings

一个人想着一个人 提交于 2019-12-18 07:41:13
问题 How can I specify output directory when I create DeploymentItem in testsettings? It is easy when you apply DeploymentItem attribute to method or class (there is a special constructor parameter) but I don't see a way to apply it in testsettings (and even UI doesn't contain anything like this). 回答1: Try editing the testrunconfig file either from VS or using an XML editor - right-click and choose open with and add a line like this one: <Deployment> <DeploymentItem filename="rootdir\SomeDir\"

Run tests in 64-bit

杀马特。学长 韩版系。学妹 提交于 2019-12-18 05:43:14
问题 I got a ADO.NET driver which is compiled as 64-bit. I therefore need to run mstests in 64-bit mode. Is that possible? (the dev machine is 64bit). 回答1: Visual Studio has a built in option for this. It was a bit hard to find (if you do not know where to look). Doubleclick on the local.testsettings file in Solution Explorer and select Hosts in the listbox. Then change as the image shows. You must do your tests in a 64-bit OS and your application should be compiled with AnyCPU . 回答2: Try the

TeamCity Setting up MSTest 2012

╄→гoц情女王★ 提交于 2019-12-18 05:41:51
问题 On the TeamCity server we have installed VS 2012. I have created a build configuration in TeamCity that builds and deploys the solution. I have added a MSTest 2012 Configuration as well, but don't know how to tell it what project is the VS 2012 test project so that it can run those tests. Thanks 回答1: You need to specify assembly file (dll) of your tests, not the project file (csproj). Here's an example: http://shrani.si/f/p/PH/2tO4Zo5s/tmpa4cc.jpg So let's say your Testing assembly is called

TeamCity Setting up MSTest 2012

感情迁移 提交于 2019-12-18 05:41:23
问题 On the TeamCity server we have installed VS 2012. I have created a build configuration in TeamCity that builds and deploys the solution. I have added a MSTest 2012 Configuration as well, but don't know how to tell it what project is the VS 2012 test project so that it can run those tests. Thanks 回答1: You need to specify assembly file (dll) of your tests, not the project file (csproj). Here's an example: http://shrani.si/f/p/PH/2tO4Zo5s/tmpa4cc.jpg So let's say your Testing assembly is called

Selenium WebDriver.ChromeDriver Nuget package installed, but not working for MSTest

这一生的挚爱 提交于 2019-12-18 04:40:43
问题 I have added the WebDriver.ChromeDriver nuget package to my solution, which contains the ChromeDriver.exe file, required for Selenium WebDriver to run automated tests using Chrome. Looking at the package contents, it just contains the file following file: tools\chromedriver.exe What this is supposed to do is add this folder to the PATH environment variable so that chromedriver.exe is accessible via the following code (this is in a UnitTest project using MSTest): [TestMethod] public void