mstest

TFS not deploying referenced assembly to test dir when on build server

荒凉一梦 提交于 2019-11-30 05:50:20
问题 I have Coded-UI test project that has references to other assemblies in solution. Somehow some assemblies are not copied to TestResults/Out directory, while others are copied. All assemblies have Copy Local option true (don't know if it really matters though) and are absolutely equal in other options. All assemblies are copied when I start test locally from VS2010, but not when on build server. If I use [DeploymentItem] attribute to force deployment of these "naughty" assemblies they deploy

Add custom message to unit test result

你说的曾经没有我的故事 提交于 2019-11-30 05:40:21
Is there a way I can add a custom message to the result of a test method? I want to put a stopwatch on part of the code to see how long its running. I don't need to test that it's running within a certain time frame, just want to see in the result window what the elapsed time was. Assuming you are using MSTest, you can use System.Diagnostics.Trace.WriteLine("Hello World"); To output whatever you'd like. It will show up in the full results of the test runner. The example above did not work for me but the following did: var result = routeManager.UpdateWalkingOrder(previouspremiseFuncLoc,

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

做~自己de王妃 提交于 2019-11-30 05:27:53
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 myself, the data-driven tests run, but they do not pick up the data created in [ClassInitialize]: it

How does the Visual Studio 2012 test runner apply threading?

孤人 提交于 2019-11-30 05:27:26
问题 Does each Class containing tests run in it's own thread? Or does each individual test run in it's own thread? If each Class containing tests has its own thread, are these run concurrently? ie, would tests from class A run concurrently with tests from Class B? Or would class A's tests run (each on their own thread), followed by tests from Class B (each on their own thread)? 回答1: Does each Class containing tests run in it's own thread? No. All tests run on the same thread Or does each

Understanding the MSTest TestContext

China☆狼群 提交于 2019-11-30 04:46:16
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 { [TestClass] public class UnitTest1 { public TestContext TestContext { get; set; } private static TestContext

Stepping through and debugging code in Unit tests

陌路散爱 提交于 2019-11-30 04:11:29
I have not been able to debug or step through unit test. Here is my sample test code... using System; using System.Text; using System.Collections.Generic; using System.Linq; using Microsoft.VisualStudio.TestTools.UnitTesting; using DomainModel.Entities; using DomainModel.Abstract; using WebUI.Controllers; namespace Tests { [TestClass] public class PeopleControllerTests { static IPeopleRepository MockPeopleRepository(params Person[] people) { var mockPeopleRepos = new Moq.Mock<IPeopleRepository>(); mockPeopleRepos.Setup(x => x.People).Returns(people.AsQueryable()); return mockPeopleRepos.Object

Running VSTS tests without mstest.exe

不羁的心 提交于 2019-11-30 03:59:48
From reasons I won't get into, all our unit tests are using the VSTS test framework. I now want to create an MSBuild script that runs the tests, but I don't want to use mstest.exe from various reasons (it's slower, requires Visual Studio installation everywhere, I need to maintain testrunconfig, etc.) I've seen that TestDriven.net and TeamCity are able to run VSTS tests 'NUnit style', without using mstest.exe. Are you aware of any standalone command line utility that does this? You can execute Team System Tests (MSTest) in NUnit if you use a special NUnit Addin that recognizes the MS Test

How to fix 'Microsoft.NETCore.App', version '1.1.2' was not found?

ε祈祈猫儿з 提交于 2019-11-30 03:37:15
I am seeing this error when I try to run unit tests: Testhost process exited with error: It was not possible to find any compatible framework version The specified framework 'Microsoft.NETCore.App', version '1.1.2' was not found. - Check application dependencies and target a framework version installed at: \ - Alternatively, install the framework version '1.1.2'. How to fix it? Installing DotNetCore.1.0.5_1.1.2-WindowsHosting solved the problem for me and my collegues. abdallah mahmoud The error tells you that you need to download Microsoft.NETCore.App , version 1.1.2 you can install it

NUnit vs Visual Studio 2010's MSTest?

蹲街弑〆低调 提交于 2019-11-30 02:42:14
I realise that there are many older questions addressing the general question of NUnit v MSTest for versions of Visual Studio up to 2008 (such as this one ). Microsoft have a history of getting things right in their 3rd version. For MSTest, that is VS2010. Have they done so with MSTest ? Would you use it in a new project in preference to NUnit? My specific concerns: speed running tests within CruiseControl.NET (either commandline or MSBuild task) code coverage reports from CC.NET can you run MSTest tests in debug mode (We use ReSharper, so test-runners are not an issue for us. We have used

Using Post-Build Event To Execute Unit Tests With MS Test in .NET 2.0+

天涯浪子 提交于 2019-11-30 02:40:20
问题 I'm trying to setup a post-build event in .NET 3.5 that will run a suite of unit tests w/ MS test. I found this post that shows how to call a bat file using MbUnit but I'm wanting to see if anyone has done this type of thing w/ MS Test? If so, I would be interested in a sample of what the bat file would look like 回答1: We were using NUnit in the same style and decided to move to MSTest. When doing so, we just added the following to our Post-Build event of the applicable MSTest project: CD $