vs-unit-testing-framework Questions

4

Solved

I am using MS unit testing framework for testing my C# library. I have to open a file which I'm deploying using DeploymentItem attribute. But it is not deploying file to the Test deployment directo...

6

Solved

Using the Visual Studio Unit Testing Framework, I'm looking at two options: Assert.AreEqual(myObject.GetType(), typeof(MyObject)); and Assert.IsInstanceOfType(myObject, typeof(MyObject)); Is ...
Roxyroy asked 12/3, 2014 at 20:6

11

Solved

NUnit has a feature called Values, like below: [Test] public void MyTest( [Values(1,2,3)] int x, [Values("A","B")] string s) { // ... } This means that the test method will ...
Abstruse asked 26/1, 2012 at 16:50

7

Solved

When trying to open an older solution in VS2017 there is an old Unit Test project that is giving me a problem when building. I keep getting the following error when building this test project: ...

7

I added these method in a TestBase class : [ClassInitialize] public static void InitializBeforeAllTests() { } But when I run in Debug an unit test Test1() : [TestClass] public class TestMapping...
Magnoliamagnoliaceous asked 6/9, 2011 at 15:13

14

Solved

I've got a C# .NET class library MyClassLibrary that compiles fine. I'm trying to create a unit test project for it (using Visual Studio Unit Testing Framework, with Visual Studio 2010). The class ...
Presentationism asked 20/4, 2011 at 19:36

4

I have a library with unittest helper classes. I reference NUnit in this project but now Visual Studio thinks this project is a test project and complains that there are no tests discovered. This p...
Arguseyed asked 15/9, 2018 at 14:32

3

Solved

In Nunit one can reuse a test method for multiple cases. [TestCase(12,3,4)] [TestCase(12,2,6)] [TestCase(12,4,3)] public void DivideTest(int n, int d, int q) { Assert.AreEqual( q, n / d ); } Ho...
Airworthy asked 12/9, 2012 at 15:15

25

Solved

How do I use Assert (or other Test class) to verify that an exception has been thrown when using MSTest/Microsoft.VisualStudio.TestTools.UnitTesting?

6

Solved

I am writing some unit tests using Visual Studio's integrated framework. I need to write some test cases which pass when a proper exception is thrown. The problem is that the exceptions i need to t...
Gymnasium asked 26/1, 2015 at 14:20

33

I'm not sure what I did, but all of a sudden, my Visual Studio 2012 will not debug any tests. If I select a test from the Test Explorer and tell it to run, it simply outputs this in the Test Outpu...

2

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 th...
Shool asked 10/4, 2014 at 21:55

9

Solved

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 ...

9

Reading through https://msdn.microsoft.com/en-us/library/jj635153.aspx I have created a .RunSettings files with a few parameters similar to the example: <TestRunParameters> <Parameter n...

5

Solved

I am writing a unit test for a controller like this: public HttpResponseMessage PostLogin(LoginModel model) { if (!ModelState.IsValid) return new HttpResponseMessage(HttpStatusCode.BadRequest); ...

4

Solved

My Unit Test Source Info is being displayed side by side, rather than below the tests: How do move it so the Test Display is below the tests, rather than beside it? Update Interesting, when I ...
Ladyfinger asked 2/2, 2015 at 15:55

2

Solved

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 ...
Rutabaga asked 1/3, 2012 at 20:10

1

I have some solutions with a bunch of projects and we have no unit test project in these solutions. However Visual Studio 2017 is still trying to discover unit tests and slowing down our process. ...

1

The build runs well but can not see the unit test result When added a build pipeline which used a classic edit or for my solution. And the code coverage also blank. I have two projects and tests p...

2

Solved

I keep the test data for specific test method in folder named the same as function. I previously had the same function call in each [TestMethod], ClearAllAndLoadTestMethodData() which determined th...
Groggery asked 30/8, 2012 at 9:56

3

Solved

The bug is very old but MS didn't fix it so far. I had a VS2015 solution (many projects, with main ASP.NET one) and I opened it in VS 2017. Here is what I saw when I tried to build it: So, I f...

3

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...
Roe asked 2/2, 2014 at 16:46

4

Solved

I have bunch of unit test I'm testing and I put the breakpoint on the unitest code and when I run with CTL+R,T instead of stopping on the breakpoint it just execute the code and I'm trying to debug...
Swordplay asked 19/12, 2011 at 18:42

5

Solved

When running code coverage for my solution which contains multiple projects, I noticed that Code Coverage includes also my test assemblies. I found an article which suggests the following templat...

2

Solved

Unable to run the unit test in visual studio 2017 professional, Run Selected Tests is disabled. I have tried to rebuild the test project and also the solution.

© 2022 - 2025 — McMap. All rights reserved.