vs-unit-testing-framework

VS2010 SP1 unit tests targeting 3.5 framework fail if using private accessor

这一生的挚爱 提交于 2019-12-04 11:35:58
I converted a solution from VS2008 to VS2010 SP1, and changed the unit test project to target the 3.5 framework. Other than having to fix a few references in the unit test project, everything worked ok and the solution built successfully. Most of the tests run successfully, but there were a handful that failed. The ones that failed are using a private accessor. Personally, I'd rather just remove these tests since I don't think they're necessary, but as long as it reveals a potential bug in SP1, I thought I'd see if anyone could figure out a work-around. The error message that I receive when

How can I default VS Test Processor Architecture to x64?

ぐ巨炮叔叔 提交于 2019-12-04 08:47:28
问题 I depend on a mixed-mode assembly which is compiled for x64. Because I do not want warnings in my build, all of the projects in my solution target x64 directly--they are not Any CPU. To get my x64 unit tests to work properly, I find that I must manually change the Visual Studio unit test Default Processor Architecture to x64 every time I start Visual Studio. This is easy enough but tedious. Is there a way to get VS to persist this setting so that I don't have to do it every time? 回答1: On

StreamWriter.WriteLine() is not working

你说的曾经没有我的故事 提交于 2019-12-04 01:07:39
问题 I am trying to write several lines, one at a time, to a .txt file using StreamWriter.WriteLine (Not statically). const string filename = "BasicTestInfo.txt"; using (var writer = new StreamWriter(filename, false)) { writer.WriteLine("{0} 350 200 200 10 2 28 20 200 2500 1200 1 1", Player1); writer.WriteLine("{0} 300 150 150 4 2 15 18 150 2500 1000 1 0", Player2); writer.WriteLine("{0} 200 140 450 25 14 10 70 4500 2500 750 1 1", Player3); writer.WriteLine("{0} 175 120 400 15 3 8 50 3000 2500 850

wildcard test containers to mstest. exe

十年热恋 提交于 2019-12-04 01:03:51
Is it possible to pass wildcard testcontainer values to the command-line mstest.exe rather than manually hardcoding multiple testcontainer values? Such as Mstest.exe /testcontainer: tests .dll I'm wanting to manually invoke mstest in our tfs 2012 upgrade template.xaml build processso tthat it behaves like a autodiscovery way similar to running tests in default template.xaml If not could this be written into a bat script to loop through folders from a given start folder? oɔɯǝɹ MSTest doesn't take a wildcard parameter for the testcontainer ( look here for a reference on the command line options

Visual Studio C# unit testing - Run Unit test with varied/multiple test initializations, Run same unit test multiple times?

我的梦境 提交于 2019-12-03 13:26:26
What i want to do is this : Create a bunch of Unit Tests. Create a variety of different permutations/combinations of initialization of mocks, input variables etc. Run each given unit test with a against a set of such initializations based on some parameters. How would i go about doing something like this? Is there already any framework to handle this (I.e. run a given test multiple times while changing initialization)? Can you suggest any design or ideas with which i could make something to do this? I am aware of unit testing frame works. i use NUnit and Rhino mocks myself. Shown below is an

Set Up Test Method with different inputs

柔情痞子 提交于 2019-12-03 05:53:30
I want to test the following method in C# for all code paths. public int foo (int x) { if(x == 1) return 1; if(x==2) return 2; else return 0; } I've seen this pex unit testing where multiple inputs are tested. How can I create a unit test that accepts multiple inputs? [TestMethod()] //some setup here?? public void fooTest() { //some assert } I want to avoid creating a test method for each input. I am working with Visual Studio 2010/2012 and .Net 4.0 You can use XML, Database, or CSV datasources MS Test . Create FooTestData.xml: <?xml version="1.0" encoding="utf-8" ?> <Rows> <Row><Data>1</Data>

How can I default VS Test Processor Architecture to x64?

穿精又带淫゛_ 提交于 2019-12-03 00:55:42
I depend on a mixed-mode assembly which is compiled for x64. Because I do not want warnings in my build, all of the projects in my solution target x64 directly--they are not Any CPU. To get my x64 unit tests to work properly, I find that I must manually change the Visual Studio unit test Default Processor Architecture to x64 every time I start Visual Studio. This is easy enough but tedious. Is there a way to get VS to persist this setting so that I don't have to do it every time? On Visual Studio 2013 I found that after setting "Default Process Architecture" to X64 I'll go and open "Options...

TF Build definition with Publish target and running unit tests

荒凉一梦 提交于 2019-12-02 21:29:26
问题 I've created a build definition using TF Build. It is the nightly build for our project. It should run the defined Unit Tests and it should package the Azure Cloud Service projects. This build has been running for some time without the packaging step. This resulted in a successful build that also ran the Unit Tests. Based on the following guide I have added the packaging of the Cloud Services: https://azure.microsoft.com/en-us/documentation/articles/cloud-services-dotnet-continuous-delivery/.

.net core projects code coverage visual studio 2017

梦想的初衷 提交于 2019-12-02 18:08:57
I am using Visual Studio Enterprise 2017 to develop my .net core projects. My solution also has some unit test projects and I want to view my current Code coverage. When I clicked Test -> Analyze Code Coverage -> All tests. All my unit tests ran but in Code Coverage Results it only reported code coverage for my unit test projects which doesn't make any sense to me. Question 1 : Do you guys experience the same issue with me? Any solution for this? I also need to set up build definition in VSTS to report code coverage. Question 2 : Also when I right clicked to debug 1 of my unit test. It

Code Coverage Results periodically gives: Empty results generated

跟風遠走 提交于 2019-12-02 01:45:36
问题 I've run into a recurring problem with a few different projects using MSTest in VS2012, where every now and then my code coverage stops working (seemingly at random) and instead gives me: 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've checked the obvious (what it's suggested) but