Questions tagged [vs-unit-testing-framework]

Microsoft's unit testing framework

123 questions with no upvoted or accepted answers
Filter by
Sorted by
Tagged with
31votes
0answers
2kviews

Unit-Test project fails to build after installing .NET 4.5

I have a WPF solution in .NET 4.0 that includes a Unit Test project which tests the different commands used in the ViewModels. Everything was working fine, but then I installed .NET 4.5 and VS2012. ...
user avatar
  • 6,875
8votes
0answers
1kviews

Visual Studio 2017 15.5 Parallel Unit Tests with Code Coverage

We've been running unit tests in parallel for several years (both with and without code coverage), following the instructions here: How to run unit tests (MSTest) in parallel? and here: Running unit ...
user avatar
  • 2,983
7votes
1answer
9kviews

Running MSTest UnitTests using a MSBuild Script

Could you please guide me how to run MSTest unit tests using an MSBuild script.
user avatar
5votes
0answers
3kviews

Visual Studio C++ unit testing (unmanaged)

I'm setting up a unit test suite for some unmanaged C++ code, and I've got some questions. Setup I added the project to my solution with Visual C++ → Test → Native Unit Test Project. Code ...
user avatar
  • 2,093
5votes
1answer
1kviews

Is it possible to avoid the build before running the unit testcase in visual studio or resharpher

Consider that i am changing only one test/unittest project, and if i try to run that it builds the unit test project(accepted) and all the other dev projects(which is not really required). how can ...
user avatar
4votes
0answers
882views

Always run unit tests on x64 in Visual Studio 2017

My projects are running on x64 platform. But the default test settings in VS2017 set X86 as a default processor architecture. It bothers me bigtime that I have to manually change the setting to X64 ...
user avatar
  • 3,558
4votes
1answer
7kviews

The type or namespace name 'VisualStudio' does not exist in the namespace 'Microsoft' (are you missing an assembly reference?)

Getting the error The type or namespace name 'VisualStudio' does not exist in the namespace 'Microsoft' (are you missing an assembly reference?) on a project using MS Test 2 Framework. I read ...
user avatar
  • 5,084
4votes
0answers
593views

TFS Test runs reporting inconsistent count of tests run each build

Using the Microsoft.TeamFoundation.Build.Activities.RunAgileTestRunner activity that shipped with VS2013RTM, I have unit tests set up like this: When I run these builds, the tests run fine, however ...
user avatar
  • 2,970
4votes
2answers
664views

code coverage for static library(.lib) visual studio

I have a static library (.lib). my test cases in my test project are in visual studio, TCs refer to many static library function. the test cases works and everything goes well. but i cant get the code ...
user avatar
3votes
1answer
1kviews

AzureDevops VSTest Task Fails: invoking executor 'executor://mstestadapter/v2': Method 'get_Properties' in type - does not have an implementation

Unit tests run fine locally. When run on the Visual Studio 2017 hosted build agent, the VSTest task fails with: 2018-12-08T10:42:16.3779907Z An exception occurred while invoking executor 'executor://...
user avatar
  • 1,771
3votes
0answers
749views

Is there a way to Ignore tests at runtime based on config property

I have a bunch of selenium test classes and I am trying to Ignore some tests without making any code changes. There are properties in appsettings with bool true/false values to determine if the ...
user avatar
  • 149
3votes
0answers
1kviews

Test Failed - Failed to set up the execution context to run the test

I am attempting to write unit tests for a set of classes that access or modify global variables. The first global I needed to wrap up was: extern std::atomic<Foo> GlobalFoo; Where Foo is an ...
user avatar
3votes
0answers
43views

Visual Studio 2013 Test - Test explorer - Debug Selected Test: is possible to view the output in real time

If I run a test in debug mode is possible to view the output in real time and not just at the end of the test? I've a compiled library that print out some debug infos (NHibernate show_sql to be more ...
user avatar
  • 6,153
3votes
0answers
202views

ClassCleanup Method Runs Too Late (or After All ClassInitialize methods)

When running multiple [TestClass]es at the same time, why do the [ClassCleanup()] methods only get called at the very end? File: UnitTest1.cs [TestClass] public class UnitTest1 { [...
user avatar
  • 1,175
2votes
0answers
127views

NSubstitute test failing only in build server

Using the NSubstite framework for mocking in c# unit testing project and recently we created version2 API controller and business and repositories. But when created the tests for the controller the ...
user avatar
2votes
0answers
151views

I need to update testcase result using gurock api

I have written code for creating a TestRun in a selected Milestone and then the testrun includes the testcase ids which needs to be updated when testcases are executed.How can I do that using Gurock ...
user avatar
  • 55
2votes
1answer
489views

How can I write a simple unit test case in c# for Microsoft Bot framework V4 as it uses .netcore now

I have to write Unit test case for BotFramework V4 simple echo method.But I am unable to find a way to mock bot. Actually I don't know where to start with. I have read all documents that I can found ...
user avatar
2votes
0answers
271views

How to invoke unit test a Print Event handler in c#

I have below method which will get invoked when I call Print() method. I need to unit test the same. Is there any suggestions on how to do this? internal PrintRemovalController(...
user avatar
2votes
0answers
348views

Universal Windows Unit Test App won't run tests

In Visual Studio 2015 Version 14.0.25422.01 Update 3 I create an empty solution with no dependencies or nuget packages I create a Unit Test App for windows universal I create a Unit Test Project I ...
user avatar
2votes
1answer
2kviews

No 'run IntelliTest' option in VS2015 Enterprise context menu

I am using VS2015 Enterprise and am trying to check out the new IntelliTest feature, but can't find the option anywhere. I created a simple function within one of my project's classes and right ...
user avatar
  • 11.7k
2votes
1answer
494views

MSTest Not Finding New Tests because of missing ProjectTypeGuids in .csproj - Why?

It happened in VS2010 that when creating project, .csproj file didn't generate some tag ProjectTypeGuids in the first PropertyGroup. This had consequence that I couldn't see in TestView window any MS ...
user avatar
2votes
0answers
283views

how to transfer query string to controller's action in unit test?

i have an Mvc controller which looks like: public class PaymentController : Controller { public ActionResult ApiReturn() { var notify_id = Request.QueryString["notify_id"]; ...
user avatar
2votes
2answers
318views

Regular expression in code coverage settings

I need to filter out some modules from the code coverage. I'm using the following regular expression: <ModulePath>.*\.i.*\.dll$</ModulePath> to exclude the following assemblies: assembly....
user avatar
2votes
0answers
186views

No 'Profile Test' context menu in Visual Studio 2012 Professional?

I have installed Visual Studio 2012 Professional, then update 2, and then update 3. In the unit test explorer, I still do not see a 'Profile Test' kind of context menu when right clicking on a test. ...
user avatar
  • 23
2votes
1answer
3kviews

"Exception occurred while test discoverer was loading tests"

I'm writing a desktop Windows 8 application, and always get this error when building the project: An exception occurred while test discoverer 'MSAppContainerTestDiscoverer' was loading tests. ...
user avatar
2votes
0answers
625views

How to raise an action through an interactivity trigger at an unittest?

i got some little problems. I want to write some unittest fora c#/wpf/interactivty project with visual studio 2010. and dont forget im a beginner, so sorry for that ;) the unittest should simulate a ...
user avatar
  • 41
1vote
1answer
92views

Only first DataRow gets executed in MSTest

I have a test with multiple DataRow(s). When executing test, it only runs first test [TestClass] public class UnitTest1 { [DataTestMethod] [DataRow(1, 2, 3)] [DataRow(2, 3, 5)] [...
user avatar
1vote
0answers
35views

App.Config GetSection not returning subsection values

I have an app.config with following Section, <configSections> <section name="Identity" type="MyProject.Test.Configuration.IdentitySection, MyProject" /> ...
user avatar
1vote
0answers
46views

Using Moq to mimic functionality

I am trying to use Moq to make my container set a value using a SetVolume function that is void and takes in an int. void SetValue(int CurrentValue); Then I need to use the value that was set in ...
user avatar
1vote
2answers
1kviews

Azure Pipeline Error: vstest.console process failed to connect to testhost process

I am converting my azure pipeline to YAML pipeline. When I trigger the build, it gets failed on the Unit test step and gives the error as below [error]vstest.console process failed to connect to ...
user avatar
  • 1,314
1vote
0answers
461views

Visual Studio Unit test: Internal Error Unable to start test host

I'm unable to run my unit test, when i run in debug mode i get the error: "Internal error: Unable to start test host. Exception: Timeout, process id not set" My test timeout is set to int.Max so it ...
user avatar
1vote
1answer
676views

WinAppDriver continuously throws an error as 'Unknown error, Operation timed out'

I'm trying to automate UI's of an extension installed in Visual Studio 2019 Enterprise using WinAppDriver and after all the successful completion of configurations and test scenarios, the WinAppDriver ...
user avatar
  • 31
1vote
0answers
296views

Test Project cannot find project dependencies

A quick google of this question brings this solution Unit test project cannot find assembly under test (or dependencies) But I have tried all the solutions in that question and none seemed to work. ...
user avatar
1vote
0answers
87views

Is it possible to test multiple resources from a .resx file in a similar way which DataRows provide?

I try to test a method on multiple sources (.eml files) and I saved those in a .resx file. I tried to access those files via DataRows and pass them as a TestMethod parameter but Visual Studio spits ...
user avatar
  • 87
1vote
0answers
485views

Asp.Net Core get culture that support also unit testing

I have a web application in asp.net core that uses MVC and RequestLocalization. Some of the controllers require the culture and I used solution from Get the current culture in a controller asp.net-...
user avatar
  • 597
1vote
0answers
185views

How to get the TestCategory name from TestContext in vb.net

I have a test method with TestCategory attribute as shown below. <TestMethod()> <TestCategory("myCategory")> Public Sub TestString() Dim a as String="a" Dim b as String="b" ...
user avatar
  • 4,871
1vote
1answer
88views

TransactionAbortedException in TestInitialize

I have a base class for my unit tests which sets up a simple transaction around every test. public class TestBase { TransactionScope _trans; [TestInitialize()] public void Init() { ...
user avatar
  • 1,691
1vote
0answers
720views

C# Unit Test Project is missing in .NET framework v4 but present in v4.5.2

I can't seem to create a Unit Test Project (.NET Framework Project) that targets .NET Framework 4.0 (see Screenshot #1) but I can create one using .NET Framework 4.5.2 (see Screenshot #2). How do I ...
user avatar
  • 13.6k
1vote
0answers
647views

C# Integration Test that calls DLL that calls ASP.NET WebAPI

Want to implement a testing scenario where an Integration Test calls a DLL Method that calls (via REST) a ASP.NET WebAPI app (all on the same solution). When I launch the test (Ctrl+R,A), the ASP.NET ...
user avatar
1vote
0answers
262views

I'd like to change vs-unit-testing-framework TimeoutAttribute result from Timeout to Passed

I'm trying to test Microsoft.VisualStudio.TestTools.UnitTesting.TimeoutAttribute. Yes, I'm trying to test the attribute itself: [Timeout(1000)] In the small sample below, the timeout attribute works ...
user avatar
1vote
1answer
445views

How to write Moq unit test for Attach() with Entityframework 6

To UPDATE a record, I have used method Attach() like var entity = new Movie() { ID = 1}; var dbEntity = DbContext.Movies.Attach(entity); dbEntity.Genre = "...
user avatar
  • 126
1vote
0answers
29views

Building Pre-existing .NET Application on Mono with Visual Studio Package Dependencies

Let me preface this by saying I'm not very familiar with .NET. I'm running a mac machine and installed mono. When I attempt the build the .NET project the below error is received. Error:CS0234: The ...
user avatar
  • 77
1vote
1answer
1kviews

why unit test project dll's are not being copied to solutions output folder using tfs quebuild?

Unit test project dll's in my solution is not being copied to solution output folder on build. I tried to add fake reference of unit test project in other project references so that msbuild will pick ...
user avatar
1vote
0answers
40views

Stop visual studio orderedtest execution if a particular test fails

My requirement is that a visual studio orderedtest execution should get stopped if a particular test fails. There is a setting "Continue After failure but setting it to false, will stop the ...
user avatar
  • 134
1vote
1answer
541views

Unit Test Adapter threw exception: Unable to load one or more of the requested types. Retrieve the LoaderExceptions property for more information

I have a windows application containing certain unit tests, whenever i try to run or debug any unit test i get the below error in test explorer- Unit Test Adapter threw exception: Unable to load ...
user avatar
1vote
1answer
1kviews

How to run a batch file during MyTestInitialize in Visual Studio Test Case

I want to run a batch file before executing each test case. The batch file will reset the things which every test case needs. So far I have tried the following: [TestInitialize()] public void ...
user avatar
1vote
0answers
338views

Running unit tests after every build in VS.Net 2013 Community

Is there any way of running tests automatically after each build? I know this is possible in 2013 Premium/Ultimate (link) but sure there are ways to do this in the Community edition? I'm using Nunit +...
user avatar
  • 1,992
1vote
2answers
149views

Exception with 64Bit Unit Test in Visual Studio 2008 Professional

I am trying to Unit-Test a 64 Bit C++/CLI-Project and therefore have a Unit-Test-Project. With 32-Bit Settings everything works fine, but when switching to 64 Bit I get an exception: Class ...
user avatar
  • 657
1vote
2answers
1kviews

moq getting nested struct from the testing class

I am writing Unit tests for the following class legacy class Class myLegacyClassPresenter { private MethodA(){} private propertyA {get; set;} private MethodB(YearValue value){} //some more ...
user avatar
  • 1,674
1vote
1answer
110views

SpecFlow Exception, while running a test under WP8 project

Trying to run SpecFlow test I receive an error: Missing resource DefaultSkeletonTemplates.sftemplates I have: The feature file Feature class (generated code) Feature step All classes bound What ...
user avatar
  • 81

15 30 50 per page