mstest

How does Visual Studio /mstest identify test projects?

亡梦爱人 提交于 2019-11-28 09:06:39
Say (100% hypothetically) that I've accidentally added a unit test project as project type "Class library" to a VS2010 solution. I've then added the assemblies needed to run it as a Unit Test project, but MSTest won't pick up on it when I hit "Run all tests in solution". What are the criterias here? I had a couple of theories, which all have failed so far: Something in the .testsettings file (no references to any assemblies here as far as I can see) Something in the .SLN file (can't find anything) Something in AssemblyInfo.cs (no, it's not) Implict by referencing the (...)UnitTestFramwork.dll

Issue with Code Coverage in VS 2012

╄→гoц情女王★ 提交于 2019-11-28 07:54:31
问题 I have a simple ASP.Net MVC 4 application with 3 simple tests. Each of these tests run successfully to completion, however the Code Coverage window gives me the following error: Empty results generated: No binaries were instrumented. Make sure the tests ran, required binaries were loaded, had matching symbol files, and were not excluded through custom settings. For more information see http://go.microsoft.com/fwlink/?LinkID=253731 I have done some research but nothing has resolved my problem

How to mock extension methods with Rhino Mock?

徘徊边缘 提交于 2019-11-28 07:40:08
问题 I have extended objects of type IDataReader with some extension methods that I needed. The problem is now when I try to mock the IDataReader, the extended method is not included in the mock so when the row Expect.Call(reader.ExtensionMethod()).Return(someValue) is reach the ExtensionMethod is executed which is not what I want! I want that call to be record and when the extension method is call from somewhere else I want it to return someValue . Does anyone know how to get around this? 回答1:

Assert.AreEqual fails while it shouldn't

…衆ロ難τιáo~ 提交于 2019-11-28 07:38:07
I have a really weird behavior which I cannot explain. I have the following class: public class Project { public virtual int Id { get; set; } public virtual string Name { get; set; } } And a method which returns a Project object: public Project GetByName(string Name) { using (ISession session = NHibernateHelper.OpenSession()) { Project project = session.CreateCriteria(typeof(Project)) .Add(Restrictions.Eq("Name", Name)) .UniqueResult<Project>(); return project; } } I have added a Unit Test to test the GetByName method: [TestMethod] public void TestGetByName() { IProjectsRepository

MSTest cannot find the assembly

早过忘川 提交于 2019-11-28 07:13:49
问题 I was using MSTest and i use command mstest /testsettings:local.Testsetting /testcontainer:folder\obj\Debug\test.dll and this is the output, Run has the following issue(s): Warning: Test Run deployment issue: The assembly or module 'Microsoft.Practices. Prism' directly or indirectly referenced by the test container 'test.dll' was not found. Warning: Test Run deployment issue: The assembly or module 'Project.Common.dll' directly or indirectly referenced by the test container 'test.dll' was not

Where is mstest.exe located?

余生长醉 提交于 2019-11-28 07:07:27
I need to run mstest from the command line - where in the world is this exe located? Can anyone give me a clue? Edit: I only have Visual Studio 2010 installed for %x in (mstest.exe) do @echo.%~dp$PATH:x from the Visual Studio Command Prompt is your friend. For me it's in C:\Program Files (x86)\Microsoft Visual Studio 9.0\Common7\IDE\ Type where mstest.exe into a Visual Studio Command Prompt... Dave Kennedy I stumbled across this post because I'm trying to automate some web tests. You can run >mstest /TestContainer:some.webtest from the visual studio command prompt, sure - but when you slap

How does Assert.AreEqual determine equality between two generic IEnumerables?

◇◆丶佛笑我妖孽 提交于 2019-11-28 05:45:26
I have a unit test to check whether a method returns the correct IEnumerable . The method builds the enumerable using yield return . The class that it is an enumerable of is below: enum TokenType { NUMBER, COMMAND, ARITHMETIC, } internal class Token { public TokenType type { get; set; } public string text { get; set; } public static bool operator == (Token lh, Token rh) { return (lh.type == rh.type) && (lh.text == rh.text); } public static bool operator != (Token lh, Token rh) { return !(lh == rh); } public override int GetHashCode() { return text.GetHashCode() % type.GetHashCode(); } public

Why does TestInitialize get fired for every test in my Visual Studio unit tests?

家住魔仙堡 提交于 2019-11-28 03:10:05
I'm using Visual Studio 2010 Beta 2. I've got a single [TestClass] , which has a [TestInitialize] , [TestCleanup] and a few [TestMethods] . Every time a test method is run, the initialize and cleanup methods are ALSO run! I was under the impression that the [TestInitialize] & [TestCleanup] should only be run once, per local test run. Is that correct? If not, what is the proper way to do this? alexn TestInitialize and TestCleanup are ran before and after each test, this is to ensure that no tests are coupled. If you want to run methods before and after ALL tests, decorate relevant methods with

How to make unit test run in bin folder

末鹿安然 提交于 2019-11-28 03:01:06
问题 I'm trying to access a file in my solution structure during the unit test. My unit test project has the bin\Debug\ as the output directory. So I have written the code assuming that Path.GetFullPath(".") in my unit test will give me this bin folder. But what it does is it gives me a temporary location as the path. C:\Users\[username]\AppData\Local\Temp\TestResults\[username]_[machine_name] 2013-05-16 08_31_07\Out So obviously my unit test couldn't access the files in my solution. If anyone

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

白昼怎懂夜的黑 提交于 2019-11-28 02:58:21
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? The standard way to do this is by specifying the deployment items in the .testrunconfig file, which can be accessed via the Edit Test Run Configurations item in the Visual Studio Test menu or in the Solution Items folder. You can