mstest

Prevent MSTest from copying / deploying every dll

烈酒焚心 提交于 2019-12-03 16:36:25
问题 When running MSTest from Visual Studio - the unit test execution time is relatively quick. When running MSTest from the command line, with /testsettings flag - the execution takes forever and that is because it spends 95% of its startup time copying the dll's to its Out folder. Is there a way to prevent this? The default Local.testsettings in the project has no modifications to it (which also means it is empty). However, if I try to use that same file from the command line, MSTest complains

How to set the working directory for MS Test projects

流过昼夜 提交于 2019-12-03 16:16:52
问题 how can I set the working directory for MS Tests projects, like I can do it for normal application projects? My Component that is tested need to access some config files that are also used by other applications. So far I have to copy these files the bin/debug folder of my test project, as these files are expected to be in the working directory. Is it possible to set a working directory for test projects? 回答1: For those who use Visual Studio 2012, if you set the output directory of the test

Is summary necessary in unit test method

∥☆過路亽.° 提交于 2019-12-03 15:44:45
问题 Since the naming of a unit test method makes its purpose more meaningful, is it necessary to add a summary to a unit test method? Example: /// <summary> /// Check the FormatException should be thrown when a give country data line contains a invalid number. /// </summary> [TestMethod] public void FormatException_Should_Thrown_When_Parse_CountryLine_Containing_InvalidNumber() { ... } 回答1: I think the long descriptive name is more important than the XML comment. Since the unit test isn't going

What command line arguments does Visual Studio use for running MsTest?

瘦欲@ 提交于 2019-12-03 14:51:43
I'm trying to figure out which is the command line arguments used by Visual Studio when you run the MsTest tests, I guess it starts with: MSTest.exe /testmetadata:%SolutionName%.vsmdi /testlist: But I couldn't figure out how to fill the testlist parameter, because both the test list name and id get the following error: The test list path 8c43105b-9dc1-4917-a39f-aa66a61bf5b6 cannot be found. An error occurred while executing the /testlist switch. I'm trying to figure out which is the command line arguments used by Visual Studio when you run the MsTest tests It depends on how do you run your

MsTest - executing method before each test in an assembly

随声附和 提交于 2019-12-03 14:27:53
问题 Is it possible to run specific method before each test in an assembly? I know about TestInitialize attribute but this attribute has "class scope". If it's defined in a Test class it will be executed before each test from this class. I want to define a method that will be executed before each test defined in a whole assembly. 回答1: I am not sure that this feature is possible in MsTest out of box like in other test frameworks (e.g. MbUnit). If I have to use MsTest, then I am solving this by

ExpectedExceptionAttribute is not working in MSTest

不打扰是莪最后的温柔 提交于 2019-12-03 14:24:50
This is weird, but all of a sudden the ExpectedExceptionAttribute quit working for me the other day. Not sure what's gone wrong. I'm running VS 2010 and VS 2005 side-by-side. It's not working in VS 2010. This test should pass, however it is failing: [TestMethod] [ExpectedException(typeof(ArgumentNullException))] public void Test_Exception() { throw new ArgumentNullException("test"); } Any ideas? This really sux. Steve Py Not to resurrect a dead thread, but I came across this when this all the sudden happened to me, in case it can help others. I did finally track down what the problem was,

Is it possible to test “internal” class from a c++ dll using MSTest?

这一生的挚爱 提交于 2019-12-03 12:59:25
We are currently trying to add unit testing to our c++ application. The application is made of 30 projects that generate 29 dll and 1 exe. We use MSTest to run our unit test since it's already included in Visual Studio 2010. It works great for class that are declared "public". These class have this at the beginning: #ifdef RESEAU_IMPL #define CLASS_DECL _declspec(dllexport) #else #define CLASS_DECL _declspec(dllimport) #endif But for all the other class (90% of the code), they are not declared public so we can't use them in our test. I've read on google about the InternalVisibleTo attribute

Why is [AssemblyInitialize] and [AssemblyCleanup] being called twice in same test project assembly?

大憨熊 提交于 2019-12-03 12:34:14
I thought the whole purpose of these attributes was to run them only once per assembly. I have a simple class as follows: [TestClass] public class AssemblyIntegrationTestSetup { public AssemblyIntegrationTestSetup() { } public TestContext TestContext { get; set; } [AssemblyInitialize] public static void SetupIntegrationTests(TestContext context) { WindowsServiceService.Instance.StartService("Distributed Transaction Coordinator"); } [AssemblyCleanup] public static void TeardownIntegrationTests() { WindowsServiceService.Instance.StopService("Distributed Transaction Coordinator"); } } However

DeploymentItem behaving differently in VS2010 and VS2012

断了今生、忘了曾经 提交于 2019-12-03 12:30:39
I have a VS2010 solution that I'm trying to upgrade to VS2012. I'm having a problem with the MSTest unit tests in VS2012. All of the tests include DeploymentItem attributes on the test class. [TestClass] [DeploymentItem(@"SubDir\SubDir2\models", "models")] public class UnitTests { ... } In 2010, it's correctly copying dependent files from the SolutionDirectory\SubDir\SubDir2\models directory. In 2012, it's attempting to copy from the directory where the tests are deployed SolutionDirectory\UnitTests\bin\debug\SubDir\SubDir2\models I'm looking for a way to restore the old behavior. If you

How can you use “external” configuration files (i.e. with configSource) with an MSTest unit test project?

廉价感情. 提交于 2019-12-03 12:06:26
问题 For simplicity, I generally split a lot of my configuration (i.e. the contents of app.config and web.config) out into separate .config files, and then reference them from the main config file using the 'configSource' attribute. For example: <appSettings configSource="appSettings.config"/> and then placing all of the key/value pairs in that appSettings.config file instead of having this in-line in the main config file: <appSettings> <add key="FirstKey" value="FirstValue"/> <add key="SecondKey"