mstest

Repeat mstest test run multiple times

北城余情 提交于 2020-01-01 08:46:49
问题 Some of my mstest unit tests help detect multi-threading race conditions, and as such they are most useful when run many times in a row, but I only want to do this for specific test runs -- not all the time. Is there a way to configure mstest (in the Test List Editor preferably) to run a test multiple times? 回答1: I needed to do something similar, so I came up with a solution to this. It's not simple, but once everything is setup you can reuse it across projects. I also have a download of this

How to mock/fake SmtpClient in a UnitTest?

大兔子大兔子 提交于 2020-01-01 04:16:27
问题 I want to use it to fake System.Net.Mail.SmtpClient in a MS-Test UnitTest. Therefor I added a Fakes Assembmly of System.dll. Then I create a ShimsContext and a StubSmtpClient . using (ShimsContext.Create()) { StubSmtpClient client = new StubSmtpClient(); } But what do I do with it? The ultimate goal would be to write a Test which expects that the send Method is called with a object of MailMessage . 回答1: You can create an interface which will expose functions that will be used from SmtpClient

MSTest.exe (VS2012) crashes QTAgent32.exe

删除回忆录丶 提交于 2019-12-31 22:34:14
问题 i am trying to execute our tests via cmdline. I use VS2012, but i always get this error: When i run the tests directly in VS2010 on the same machine they run fine. I can't use VS2010 for cmdline because we have the wrong license ( assembly finding doesn't work ) so i have to use 2012. All Windows updates are present. Has somebody had similar issues with MSTest/VS2012 ? 回答1: If you want to keep VS 2012 update 2, 3, or 4 installed, you can try the below workaround: Run the below commands in the

Explicitly call static constructor

我们两清 提交于 2019-12-31 17:49:13
问题 I want to write unit test for below class. If name is other than "MyEntity" then mgr should be blank. Negative Unit test Using Manager private accessor I want to change name to "Test" so that mgr should be null. And then will verify the mgr value. To achieve this, I want to explicitly call the static constructor but when I call the static constructor using Manager_Accessor.name = "Test" typeof(Manager).TypeInitializer.Invoke(null, null); name is always set to "MyEntity" how to set name to

Recommendations for Continuous integration for Mercurial/Kiln + MSBuild + MSTest

倖福魔咒の 提交于 2019-12-31 12:19:12
问题 We have our source code stored in Kiln/Mercurial repositories; we use MSBuild to build our product and we have Unit Tests that utilize MSTest (Visual Studio Unit Tests). What solutions exist to implement a continuous integration machine (i.e. Build machine). The requirements for this are: A build should be kicked of when necessary (i.e. code has changed in the Repositories we care about) Before the actual build, the latest version of the source code must be acquired from the repository we are

NUnit doesn't find tests in assembly

北城余情 提交于 2019-12-30 10:51:55
问题 I inherited an assembly with MSTest, but these tests were run using nunit-console on the build machine (not sure how it worked). So I decided to sort it out and change them to proper NUnit tests, but now nunit-console (or gui) can't find any tests. They run just fine using ReSharper test runner though. Any idea what could be missing? 回答1: Check: Is the class public? Does it have a public parameterless constructor (e.g. the default one if you don't specify any other constructors) Does it have

Why do my tests fail with System.Security.VerificationException?

混江龙づ霸主 提交于 2019-12-30 07:21:12
问题 I'm in the process of migrating one of my projects from VS2008 to VS2010. Now that I converted all of my projects in the solution to .NET 4.0 (Client Profile) when I run the test harness, almost all tests fail with the following exception: System.Security.VerificationException: Operation could destabilize the runtime. I've been unable to determine why this exception occurs. The tests run all fine when I run them in debug mode. The entire solution is available for download here. Can anyone

Using MS Test ClassInitialize() and TestInitialize() in VS2010 as opposed to NUnit

不打扰是莪最后的温柔 提交于 2019-12-30 05:34:12
问题 I've used NUnit with VS2008, and now am adapting to MSTest on VS2010. I used to be able to create an object in TestSetup() and dispose of it in TestCleanup(), and have the object created each time a test method was run in NUnit, preventing me from duplicating the code in each test method. Is this not possible with MSTest? The examples I am finding using the ClassInitialize and ClassCleanup and TestInitialize and TestCleanup attributes only show how to write to the console. None show any more

how does MSTest determine the order in which to run test methods?

耗尽温柔 提交于 2019-12-30 03:44:29
问题 edit: note, question 288805 is similar, however, I specifically am asking how does MSTest choose the default test order. Please see the rest of this question. Thank you Eilon for the link. I was looking at a legacy MSTest project. The tests were always running in the same order. The order was not alphabetic and was bouncing between methods in two *.cs TestMethod files. I did not change the physical order of the legacy code. I did for my convenience append "MSTest01" to the method name of the

Visual Studio 2013 is unable to open the Test Window

霸气de小男生 提交于 2019-12-28 16:45:31
问题 When I open Visual Studio 2013 and load my solution I'm greeted by an error message telling me the Test Window is unable to load. The composition produced a single composition error. The root cause is provided below. Review the CompositionException.Errors property for more detailed information. 1) Cannot compose part 'Microsoft.VisualStudio.TestWindow.Controller.TestsServiceInternal' because a cycle exists in the dependencies between the exports being composed. To break this cycle, consider