mstest

Resharper Unit Test Runner Can't Find Content Files

限于喜欢 提交于 2019-11-30 23:17:47
问题 I have some tests that rely on some files I have marked as "Content" and to "Always Copy". I'm using the DeploymentItem attribute to make sure they get copied to the output directory when running mstest outside of VS. However when using the Resharper test runner inside VS these files never make it to the directory that it is executing from. Anyone know how to fix this? 回答1: Disabling the Unit Testing > Shadow-copy assemblies being tested Resharper option fixed this problem for me. 回答2: We

how to add synchronization context to async test method

佐手、 提交于 2019-11-30 22:38:57
I have Visual Studio 2012 and an asynchronous test that needs a synchronization context. But the default synchronization context of MSTest is null. I would like to test as running on a WPF- or WinForms-UI thread that has a synchronization context. What's the best method to add a SynchronizationContext to the test thread ? [TestMethod] public async Task MyTest() { Assert.IsNotNull( SynchronizationContext.Current ); await MyTestAsync(); DoSomethingOnTheSameThread(); } Using the informations from Panagiotis Kanavos and Stephen Cleary, I can write my testmethods like this: [TestMethod] public void

Visual Studio Test Project - Does not copy folder on deployment

六眼飞鱼酱① 提交于 2019-11-30 22:31:03
问题 Here is the problem: 1. Create a TestProject in your Visual Studio solution. 2. Open the .testrunconfig file and under the 'deployment' menu item, select the 'Enable Deployment' checkbox. 3. Now click on 'Add Directory...' button and add a folder which has some files in it. 4. Run the test project (use a dummy test). Ok, now go check the TestResults folder: You will see that all the files got directly copied (to the top level)- the folder itself is not copied (with the files under them). This

Convert Trx into Html using TRXER

僤鯓⒐⒋嵵緔 提交于 2019-11-30 19:32:28
Just released a new tool called TRXER. Git link : https://github.com/NivNavick/trxer All it does is tramsform TRX file (mstest results file) into html. The Html as shown below is clean,nice and understandable. You can see the pie indicates statuses count and a table that includes test classes that contains the tests themselves. You can view the release note here https://github.com/NivNavick/trxer Hope you will love this product and find it useful. Best regards :) Nice work! The "Show Tests" link works right ? 来源: https://stackoverflow.com/questions/29593251/convert-trx-into-html-using-trxer

Why MSTest does not copy referenced project libraries?

有些话、适合烂在心里 提交于 2019-11-30 17:35:13
I have a Visual Studio solution with a C# dll project. This solution has also a test project which references the output of the C# dll project. The referenced project dll has set Copy Local = true. If I run this test from the Visual Studio, it works fine. But if I run it from the MSBuild task, for some reason MSTest does not copy the referenced C# dll to the MSTest working folder, so the test fails. The weird thing is, that all the other referenced libaries are copied to the MSTest working folder. And if I put a [DeploymentItem(@"PleaseCopyThis.dll")] before my test method, finally it is

Inherited test class from generic base is ignored in MSTest

断了今生、忘了曾经 提交于 2019-11-30 17:17:36
When creating a generic base test class in MSTest, and inheriting from it, I'm unable to run the tests of all the inheriting classes. BaseDependencyPropertyFactoryTest is located in the Whathecode.PresentationFramework.Tests assembly. It is the generic base class. ( BaseDependencyPropertyFactoryTest<TTestClass> ) Both assemblies have a test inheriting from this base class, called DependencyPropertyFactoryTest . All the inherited class does is passing a specific type argument. [TestClass] public class DependencyPropertyFactoryTest : BaseDependencyPropertyFactoryTest<ASpecificClass> { } Only the

MSTEST PrincipalPermission

眉间皱痕 提交于 2019-11-30 17:09:55
How do you unit test code decorated with the PrincipalPermission attribute? For example, this works: class Program { static void Main(string[] args) { AppDomain.CurrentDomain.SetPrincipalPolicy(PrincipalPolicy.WindowsPrincipal); var c = new MyClass(); } } [PrincipalPermission(SecurityAction.Demand, Role = @"BUILTIN\Users")] class MyClass { public MyClass() { Console.WriteLine("This works."); } } This throws a SecurityException: [TestClass] public class UnitTest1 { [TestInitialize] public void TestInitialize() { AppDomain.CurrentDomain.SetPrincipalPolicy(PrincipalPolicy.WindowsPrincipal); }

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

时光怂恿深爱的人放手 提交于 2019-11-30 17:06:14
问题 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

Assert exception from NUnit to MS TEST

瘦欲@ 提交于 2019-11-30 16:41:21
问题 I have some tests where i am checking for parameter name in exception. How do i write this in MS TEST? ArgumentNullException exception = Assert.Throws<ArgumentNullException>( () => new NHibernateLawbaseCaseDataLoader( null, _mockExRepository, _mockBenRepository)); Assert.AreEqual("lawbaseFixedContactRepository", exception.ParamName); I have been hoping for neater way so i can avoid using try catch block in the tests. 回答1: public static class ExceptionAssert { public static T Throws<T>(Action

What is required for doing Unit Tests on a Build Server?

泄露秘密 提交于 2019-11-30 14:33:53
I am doing unit tests (no additional frameworks other then what comes out of the box with VS 2013). It all works locally. What do I need to do to get it working on the build server? The build server is a TFS 2013. There are no visual studio installed other then an 2010 version. I have already moved all the 4.5 .net stuff and .targets files from my visual studio to the build server to be able to compile 4.5 dlls and azure projects. First I had problem with the build template was using AgileRunner or something thats coming with VS2013. I changed that to MSTest. Is this the correct change? Is