mstest

MSTest: CollectionAssert.AreEquivalent failed. The expected collection contains 1 occurrence(s) of

妖精的绣舞 提交于 2019-11-27 01:32:59
问题 Question : Can anyone tell me why my unit test is failing with this error message? CollectionAssert.AreEquivalent failed. The expected collection contains 1 occurrence(s) of . The actual collection contains 0 occurrence(s). Goal : I'd like to check if two lists are identical. They are identical if both contain the same elements with the same property values. The order is irrelevant. Code example : This is the code which produces the error. list1 and list2 are identical, i.e. a copy-paste of

How can I use PrivateObject to access private members of both my class and its parent?

帅比萌擦擦* 提交于 2019-11-27 01:11:11
问题 I'm testing a class that is part of a hierarchy. I've been setting up my test classes with the object under test, and a PrivateObject to allow access to that object. I'm getting exceptions when I attempt to access private members of the parent class. The only workaround I've found so far is to pass a PrivateType specifying the base class to the PrivateObject constructor, but then it doesn't work on private members of the subclass. Is there some way I can do this, perhaps by using the binding

How to write to Console.Out during execution of an MSTest test

元气小坏坏 提交于 2019-11-27 00:01:04
Context: We have some users reporting issues with a file upload feature in our web application. It only happens occasionally and without any special pattern. We have been trying to figure it out for a long time, adding debug information anywhere we can think it might help, crawling the logs etc, but we have not been able to reproduce or figure it out. Problem: I'm now trying to reproduce this by using MSTest and WatiN to repeat the operation that is supposed to fail a large number of times (several hundreds). Just to have a clue about how far in the loop the test has gotten, I want to print

How can I get “Copy to Output Directory” to work with Unit Tests?

二次信任 提交于 2019-11-26 23:54:03
问题 When I build a unit test project before the tests are executed the test output is copied to a TestResults folder and then the tests are executed. The issue I'm having is that not all the files in the Debug/bin directory are copied to the TestResults project. How can I get a file that is copied to the Debug/bin directory to also be copied to the TestResults folder? 回答1: The standard way to do this is by specifying the deployment items in the .testrunconfig file, which can be accessed via the

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

两盒软妹~` 提交于 2019-11-26 23:24:25
问题 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

Switching Between Using NUnit and MSTest for Unit Testing

不羁的心 提交于 2019-11-26 22:40:19
问题 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

Problems with DeploymentItem attribute

你离开我真会死。 提交于 2019-11-26 22:35:20
问题 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

MSTest copy file to test run folder

不想你离开。 提交于 2019-11-26 18:58:32
问题 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) 回答1: 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

TestInitialize vs ClassInitialize

て烟熏妆下的殇ゞ 提交于 2019-11-26 18:07:06
问题 What is the difference between TestInitialize vs ClassInitialize in MSTest? What are the pros cons of each? I'm under the impression that TestInitialze should run with EACH test, every time? Is that correct? And that ClassInitialize will run every time a new instance of any class? 回答1: Both attributes are available only for the classes (and hence tests) where they belong. TestInitialize runs before every test that is declared on the the same class where the attribute is declared.

How to RowTest with MSTest?

一世执手 提交于 2019-11-26 17:42:34
I know that MSTest doesn't support RowTest and similar tests. What do MSTests users do? How is it possible to live without RowTest support? I've seen DataDriven test features but sounds like too much overhead, is there any 3rd party patch or tool which allow me to do RowTest similar tests in MSTest ? [TestMethod] Test1Row1 { Test1(1,4,5); } [TestMethod] Test1Row2 { Test1(1,7,8); } private Test1(int i, int j, int k) { //all code and assertions in here } I know this is a late answer but hopefully it helps others out. I looked everywhere for an elegant solution and ended up writing one myself. We