mstest

How to prevent expected exceptions from breaking the debug test run?

旧城冷巷雨未停 提交于 2019-11-28 02:57:47
问题 When running MSTEST unit tests in debug mode, the execution stops in every expected exception that is thrown. My test looks like this [TestMethod()] [ExpectedException(typeof(ArgumentNullException))] public void ShouldThrowExceptionWhenPassingNull() { object data = null; target.CheckNull(data); } the target method looks like this: public void CheckNull(object data) { if (ReferenceEquals(null, data)) { throw new ArgumentNullException("data"); } } // test run breaks here: ArgumentNullException

Running MSTEST.exe /publish on a TeamBuild server, what are the prerequisites?

拜拜、爱过 提交于 2019-11-28 00:21:20
Similarly to How to use MsTest in Continuous Integration without VS? , I want to run mstest.exe on a TeamBuild server. My context is Trapping Error Status in MSBuild - i.e., I'm only trying to use mstest.exe /publish to upload the results in to the TFS repository. Thus the full rigmarole in http://www.shunra.com/shunrablog/index.php/2009/04/23/running-mstest-without-visual-studio/ is (you'd hope) likely to be overkill, esp as MSTEST.exe, as covered in http://social.msdn.microsoft.com/Forums/en-US/tfsgeneral/thread/e4575890-8f88-413c-a7f3-0d09d3b9cb01 suggests all I need to do is install Team

Forcing MSTest to use a single thread

故事扮演 提交于 2019-11-27 21:03:26
Given this test fixture: [TestClass] public class MSTestThreads { [TestMethod] public void Test1() { Trace.WriteLine(Thread.CurrentThread.ManagedThreadId); } [TestMethod] public void Test2() { Trace.WriteLine(Thread.CurrentThread.ManagedThreadId); } } Running the test with MSTest through Visual Studio or command line prints two different thread numbers (yet they are run sequentially anyway). Is there a way to force MSTest to run them using a single thread? detroitpro I've fought for endless hours to make MSTest run in a single threaded mode on a large project that made heavy use of nHibernate

MsTest ClassInitialize and Inheritance

巧了我就是萌 提交于 2019-11-27 20:57:59
I have a base class for my tests which is composed in the following way: [TestClass] public abstract class MyBaseTest { protected static string myField = ""; [ClassInitialize] public static void ClassInitialize(TestContext context) { // static field initialization myField = "new value"; } } Now I am trying to create a new test that inherits from the base, with the following signature: [TestClass] public class MyTest : MyBaseTest { [TestMethod] public void BaseMethod_ShouldHave_FieldInitialized() { Assert.IsTrue(myField == "new value"); } } The ClassInitialize is never called by the child tests

Running VS2010 UnitTests project from TFS2008 Team Build

妖精的绣舞 提交于 2019-11-27 19:05:23
问题 I have a Visual Studio 2010 MVC 3 application with unit tests projects in it. I have a TFS 2008 build definition to build the solution. On the build agent i have got following installed VS2008 team system developer edition VS2010 Professional installed I have updated the msbuildpath in the tfsservice.exe.config to .NET 4 farmework Deleted all the workspaces Have followed all the steps at http://blog.aggregatedintelligence.com/2011/03/vs2010-tfs-2008-and-unit-tests.html But when i run the

Switching Between Using NUnit and MSTest for Unit Testing

若如初见. 提交于 2019-11-27 18:23:45
How can I configure a .NET solution (C#, .NET 2.0) to to allow other developers to make use of the same unit tests for the solution using either NUnit or MSTest? Background: In this project, some developers use VS2005 Team Edition, and others make use of VS2005 Pro, so not all of the developers are able to run MSTest. Given that this is an Enterprise project, the team is not able to make use of TestDriven.net or ReSharper. I am aware using either of these products with VS would resolve this issue, but given the time it would take to authorize the purchase of licenses, buying either of these

Problems with DeploymentItem attribute

六眼飞鱼酱① 提交于 2019-11-27 17:39:17
I'm currently maintaining an "old" system written in C#.net, removing some obsolete features and doing some refactoring. Thanks god, the previous guy wrote some unit tests (MSTests). I quite comfortable with JUnit tests, but didn't do yet much with MSTests. The test methods have a DeploymentItem attribute, specifying a text file which is parsed by the business logic method that is being tested and a 2nd DeploymentItem where just a path has been specified containing a bunch of TIF files that have to be deployed too. [TestMethod()] [DeploymentItem(@"files\valid\valid_entries.txt")]

Is there an API for running Visual Studio Unit Tests programmatically?

你说的曾经没有我的故事 提交于 2019-11-27 17:36:17
问题 Is there an API for running Visual Studio Unit Tests programmatically? Running MSTests.exe with Process.Start() does not work in the current scenario. What I'm looking for is something like the NUnit SimpleTestRunner. Any ideas? /Erik 回答1: You're correct in that there's no public API for the mstest framework. I wrote a manual replacement for mstest one day to see how hard it was, and it's not as simple as it looks (particularly if you want to take advantage of more than one CPU core), so

Error debugging code in visual studio 2012 - Failed to initialize client proxy: could not connect to

为君一笑 提交于 2019-11-27 17:27:20
问题 I am having Issues debugging unit tests in visual studio. I can run them fine from test explorer. The issue is that I cannot step into the code and debug. Also, I am able to debug other parts of the code that are not unit tests. When I right click on the test from test explorer and click debug I get a loading dialog saying "Loading symbols for vstest.executionengine.x86.exe from f:\biniaries\vset\mstestexecutor.x8g.csproj_1420192002\objr\x86". After a few more of these the test stops running

MSTest copy file to test run folder

扶醉桌前 提交于 2019-11-27 17:25:20
I've got a test which requires an XML file to be read in and then parsed. How can I have this file copied into the test run folder each time? The XML file is set to "Copy if newer" and a compile mode of "none" (since it's not really a compile-able thing) Preet Sangha use a DeploymentItem attribute using System; using System.IO; using Microsoft.VisualStudio.TestTools.UnitTesting; using CarMaker; namespace DeploymentTest { [TestClass] public class UnitTest1 { [TestMethod()] [DeploymentItem("testFile1.xml")] public void ConstructorTest() { string file = "testFile1.xml"; Assert.IsTrue(File.Exists