vs-unit-testing-framework

How to get test result status from MSTest?

旧巷老猫 提交于 2019-12-21 20:09:05
问题 In NUnit, I can get the test result from context.Result.State . If its NUnit.Framework.TestState.Success , then I know the test passed. In MSTest, how do I get that info? I saw context.Properties.Keys , but none of them speak of the status of the test result. 回答1: Use the TestContext.CurrentTestOutcome property in the TestCleanup method: [TestClass] public class UnitTest { private TestContext TestContext { get; set; } [TestCleanup] public void TestCleanup() { if (TestContext

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

那年仲夏 提交于 2019-12-21 17:39: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

Unit Testing WPF Application with siteoforigin pack Uri

拟墨画扇 提交于 2019-12-21 17:37:41
问题 I have some unit tests that I'm writing for a WPF application, and as much as I've tried to avoid it, I have some code under test that instantiates a View. As soon as the view is instantiated, all the markup extensions, styles, etc are evaluated. To resolve this I've created a dummy Application and registered any required resources when the test assembly is initialized: [TestClass] public class AssemblyInitialize { [AssemblyInitialize] public static void SetupTestAssembly(TestContext context)

Can't add Shared Project to Visual Studio Test Project

眉间皱痕 提交于 2019-12-21 07:29:46
问题 I'm using Visual Studio 2015 I have a Shared Project as an Independent Solution (A collection of Extensions used in several others Solutions). I want to TEST the Shared Project (Independently any other solution). So, I add a new TEST Project. But, in my TEST Project I can't add ANY reference to the Shared Project (No option). 回答1: You can edit the project's csproj file and at end of imports add an entry like <Import Project="..\SharedProject\SharedProject.projitems" Label="Shared" /> changing

Can't add Shared Project to Visual Studio Test Project

ε祈祈猫儿з 提交于 2019-12-21 07:29:07
问题 I'm using Visual Studio 2015 I have a Shared Project as an Independent Solution (A collection of Extensions used in several others Solutions). I want to TEST the Shared Project (Independently any other solution). So, I add a new TEST Project. But, in my TEST Project I can't add ANY reference to the Shared Project (No option). 回答1: You can edit the project's csproj file and at end of imports add an entry like <Import Project="..\SharedProject\SharedProject.projitems" Label="Shared" /> changing

Set Up Test Method with different inputs

◇◆丶佛笑我妖孽 提交于 2019-12-20 18:36:21
问题 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 回答1: You can use XML, Database, or CSV

.net core projects code coverage visual studio 2017

。_饼干妹妹 提交于 2019-12-20 09:15: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

Resharper 8.1 Test Runner slowing down Visual Studio Text Editing

坚强是说给别人听的谎言 提交于 2019-12-19 05:33:11
问题 I've got a fairly small C# solution with about 5 projects in it. I am using Visual Studio 2012 with Update 4, and Resharper 8.1 (build 8.1.23.546). It's on an I7 with an SSD and 16GB RAM, with oodles of disk space. Performance on this machine is fantastic for everything else. I have R# set to be my unit test runner, and I've noticed that as soon as I run any unit tests (one or many, pass or fail, makes no difference), the Visual Studio text editor becomes almost unusable. Typing into the

Resharper 8.1 Test Runner slowing down Visual Studio Text Editing

孤街醉人 提交于 2019-12-19 05:33:10
问题 I've got a fairly small C# solution with about 5 projects in it. I am using Visual Studio 2012 with Update 4, and Resharper 8.1 (build 8.1.23.546). It's on an I7 with an SSD and 16GB RAM, with oodles of disk space. Performance on this machine is fantastic for everything else. I have R# set to be my unit test runner, and I've noticed that as soon as I run any unit tests (one or many, pass or fail, makes no difference), the Visual Studio text editor becomes almost unusable. Typing into the

Visual Studio Team Test: How to unit test “?” operator with only Asserts() and not using any tool

喜欢而已 提交于 2019-12-13 12:44:05
问题 I need to write some unit test cases to test my code in C# Visual Studio Team Test framework. Below is the method I want to test: public static ObjectID CreateObjectID(ObjectID xrmObjectID) { return new ObjectID { Id = xrmAssociation.ID != null ? xrmAssociation.ID.Id : Guid.Empty; }; } In the above method, I need to write unit test cases to cover the conditional statements, for example: Id = xrmAssociation.ID != null ? xrmAssociation.ID.Id : Guid.Empty; So I wrote the following unit test