Questions tagged [mstest]

Microsoft .NET Unit Testing Framework (MSTest)

mstest
1,080 questions with no upvoted or accepted answers
Filter by
Sorted by
Tagged with
57 votes
1 answer
3k views

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. ...
atiyar's user avatar
  • 8,062
15 votes
1 answer
2k views

How to stop MsTest tests execution on first failure?

We are running nightly builds which at the end run all of our UnitTest using the MsTest framework. We must have 100% pass rate, so if one fails there is no point running the others; hence we will ...
Alon1980's user avatar
  • 1,255
14 votes
1 answer
1k views

How to handle currentDomain.UnhandledException in MSTest

I tried to implement solution based on answer How to handle exceptions raised in other threads when unit testing?, but I still don't understand what to do in the handler. Let's suppose I have a test: ...
Tomas Kubes's user avatar
  • 24.6k
14 votes
2 answers
2k views

How to create a Unit Test for an object that depends on DbEntityEntry

I have the following helper method, which takes the validation messages out of the DbEntityValidationException. We need this because the details of validation aren't added to the Exception by default. ...
Josh's user avatar
  • 8,401
11 votes
0 answers
2k views

mstest does not copy a library referenced in a project but is used at run-time only

I have a project that uses Microsoft Enterprise Library and uses configuration to specify a type for caching manager. Loaded in this manner caching manager depends on a library Microsoft.Practices....
THX-1138's user avatar
  • 21.5k
10 votes
2 answers
2k views

Can mstest run without creating test results?

I'm trying to run mstest from command prompt as guided here. It works fine but I don't want to create the test results folder or test results every time it runs. How can I achieve that? If it creates ...
Bravo11's user avatar
  • 908
9 votes
0 answers
727 views

Unit test .Net Framework 3.5 project in VS 2017

I have some legacy projects with test libraries. The projects (and unit tests) target .NET 3.5. We are using VS 2017 enterprise. I was able to locate some nuGet packages that would allow the tests to ...
Richard Hauer's user avatar
8 votes
0 answers
1k views

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 ...
James's user avatar
  • 3,768
8 votes
0 answers
666 views

MSTest launches v4.0 version of QTAgent for .NET v4.5.2 test Assembly

If I build a test assembly with target framework v4.5 and run MSTest on it, it will launch an instance of QTAgent32.exe. However, if I set the target framework to v4.5.2 and run MSTest it will instead ...
Anders Forsgren's user avatar
8 votes
0 answers
682 views

Code Coverage VSMDI on Visual Studio 2012 says "There is no test with specified Id"

I have a solution that is still using VSMDI files. Running tests are still fine, but when I try to Analyze Code Coverage on the selected test, It shows "Empty results generated". Looking at the ...
Habibi's user avatar
  • 595
8 votes
1 answer
757 views

MSTest Environment.CurrentDirectory incorrect VS 2012

I am using MSTest and Visual Studio 2012 for unit testing and am encountering a difference in how it runs on two different machines with regards to Environment.CurrentDirectory calls. Both machines ...
user1770117's user avatar
8 votes
0 answers
3k views

Assembly fails to load (EEFileLoadException) under MSTest

I am trying to resolve an EEFileLoadException in an MSTest scenario that combines managed and native code. My application consists of a couple dozen DLLs: some native (unmanaged) C++, some C++/CLI, ...
dshpak's user avatar
  • 345
7 votes
0 answers
657 views

In MSTest How to access TestMethod exception in TestCleanup without using try/catch block in test method

[TestInitialize] public void SetUp() { //Do required actions before every test } [TestMethod] public void Test1() { //Actual test Assert.AreEqual(1, 0); ...
Nagesh Nagaraja's user avatar
7 votes
1 answer
951 views

VS MSTest runner locks System.Data.SQLite.dll when running in memory tests

I'm using Fluent NHibernate to run in-memory database tests (MS Test) using SQLite 1.0.66.0: [TestClass] public abstract class InMemoryDatabaseTest { private NHibernate.Cfg.Configuration ...
TheCloudlessSky's user avatar
7 votes
1 answer
9k views

Running MSTest UnitTests using a MSBuild Script

Could you please guide me how to run MSTest unit tests using an MSBuild script.
Eranga Dissanayaka's user avatar
6 votes
0 answers
1k views

How do I stop all unit test if the first one fails?

I am having like 100+ unit tests for a project, but if a special condition fails in the first test, I want the other tests to stop, or to now even start executing. How do I do that?
dezox's user avatar
  • 182
6 votes
0 answers
7k views

How to write repository unit tests with respect to Cosmos database(SQLApi + CosmosClient)

I have a class as below : public class CosmosRepository: ICosmosRepository { private ICosmoDBSettings cosmoDbSettings; private CosmosClient cosmosClient; private static ...
SAREKA AVINASH's user avatar
6 votes
0 answers
6k views

Unit testing features missing for .NET Core in VS 2019 and Visual Studio Installer?

I just added a MSTest .NET Core unit test project to a solution in VS 2019 but there now don't appear to be any features for adding a new unit test file to that project. Missing Add > Unit test... ...
tomRedox's user avatar
  • 29.2k
6 votes
1 answer
1k views

MSTest - Can [DataRow] values be accessed in TestInitialize and TestCleanup?

I'm having tests like so: [DataTestMethod] [DataRow("example1")] [DataRow("example2")] public void Test_Example(string name) { // test logic } Our logging system is currently implemented in a ...
FDM's user avatar
  • 628
6 votes
0 answers
1k views

Visual Studio 2017 Does Not Discover Unit Tests

I am running .NET Framework 4.6.1 to build a test class library where I build MSTest tests (Microsoft.VisualStudio.TestTools.UnitTesting). I can run the tests absolutely fine by going into the folder ...
VSO's user avatar
  • 12.2k
6 votes
0 answers
494 views

Set mstest working directory

I'm trying to create a powershell script that executes my tests for my solution. I have 2 assemblies with tests in them. The problem is that in the tests I load files and the tests search in the ...
CSCoder's user avatar
  • 152
6 votes
1 answer
328 views

Shimmed method not used by test in Release mode

Within Visual Studio 2015 I have a test project to which I've added a fakes assembly. In the unit test itself I create a shim for a static generic method that returns an instance to the generic type, ...
Chrisgh's user avatar
  • 1,016
6 votes
0 answers
629 views

How to list all test categories from Mstest dll?

We are using MsTest for our automation tests. And each test has one or couple of categories. Is it possible to get list of all categories from my compiled mstest dll to construct a command line for ...
Stan's user avatar
  • 71
6 votes
1 answer
4k views

Jenkins with MSTest plugin : "mstest xml coverage report file not found"

In my build process, the VsTest.console tests my dll and generates a TestResults\a.trx file. The only parameter I added (more than dll path) is a .runsettings file. The .trx file is not empty, the ...
norisknofun's user avatar
6 votes
0 answers
918 views

Can MSTest Data Driven Tests Be Run in Parallel?

A similar question was asked several years ago for VisualStudio2010 and never answered here: How to parallelize a Data-Driven unit test in Visual Studio 2010? I'm hoping that perhaps this ...
mrfreester's user avatar
  • 1,981
6 votes
1 answer
1k views

Visual Studio 2013 - no longer able to run xunit tests side-by-side with MSTest

Q: Is it possible to run xunit tests side-by-side with MSTest in VS 2013? If so, what am I doing wrong? Background: I've migrated a .NET Solution from VS 2012 format to VS 2013. I was unable to get ...
CJBS's user avatar
  • 15.5k
5 votes
0 answers
986 views

Azure Pipelines - Visual Studio Test does not publish results from TestContext.WriteLine

We are using Azure DevOps to run a build that runs tests using Visual Studio Test. Everything is working fine, Console.WriteLine lines are being written to Standard Console Output.log, however ...
elgato's user avatar
  • 536
5 votes
3 answers
698 views

Unable to start test using mstest remotely with powershell

I have a problem with running mstest.exe remotely using powershell. I need it to run automated tests on other machine. I try to do the next command: Invoke-command -ComputerName remoteComputer" -...
Alexander Dylda's user avatar
5 votes
0 answers
443 views

How to include test category in visual studio test results

How do I make sure the test categories I used in my unit tests are included in the test results. So that I could use the category to filter my tests or generate a html using trx2html grouped by the ...
Sunil Buddala's user avatar
5 votes
0 answers
623 views

Run & share a single Server instance for tests in Visual Studio 2017

My Visual Studio 2017 project contains a few unit test projects. All these Tests run against one single ASP.NET Core Server. I want to start the ASP.NET Core Server once before all tests and shut it ...
Sam's user avatar
  • 28.7k
5 votes
0 answers
685 views

Run MSTests using Visual Studio Code

I'm facing an issue running MSTests from Visual Studio Code on macOS Sierra. I have added the dependency in the project.json ("Microsoft.VisualStudio.QualityTools.UnitTestFramework": "...
Umang Sardesai's user avatar
5 votes
0 answers
3k views

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 ...
cp.engr's user avatar
  • 2,381
5 votes
1 answer
810 views

Multiple ClassCleanup Attributes per Test Class

Situation: Some of my integration test classes share a common approach to setup scenarios in a database hence I provide an abstract base class. It also takes care of a full data cleanup at the end ...
Quality Catalyst's user avatar
5 votes
0 answers
1k views

MSTest Looking For DLL In Wrong Location

I have a test harness running and it was failing to run due to Type not resolved, which more specifically was a SerializationException on a bad bind. I used fuslogvw to track down where it was ...
Zach Leighton's user avatar
5 votes
0 answers
1k views

C# - reading an app.config in MSTest / Unit tests

I'm trying to work out how to (and at the same time best practice) use an app.config file in unit tests (MSTest specifically). So I have the actual project then a separate project. the actual project ...
John Joseph's user avatar
5 votes
0 answers
1k views

TeamCity - The process cannot access the file * because it is being used by another process

I'm using TeamCity to build and run my MSTest project. One job is responsible for building the project, once it has finished it triggers a second job responsible for running the compiled project ...
Howard's user avatar
  • 81
5 votes
1 answer
129 views

How to Stub the XMLDocument in VS 2013 using Microsoft Fakes

I have the below TestMethod I am testing with VS 2013 and I am using Microsoft Fakes. [TestMethod] public void ConstructorTestForCMAClass() { XmlDocument doc = new XmlDocument(); doc....
krrishna's user avatar
  • 2,078
5 votes
0 answers
762 views

Analyze Code Coverage throws error after tests are run

I get the following when I try and Analyze Code Coverage using MSTest in 2012. It happens on a new project and new tests as well. Exception was thrown: Code Coverage Analysis engine threw exception(...
Steven's user avatar
  • 870
5 votes
1 answer
1k views

Fail an MSTest from background threads

I have an integration test that uses multiple threads. I'd like any thread to be able to fail the test (and tear down the rest). However, an exception on a background thread causes MSTest to fail - ...
Rob's user avatar
  • 4,377
5 votes
1 answer
2k views

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 ...
codechef's user avatar
5 votes
1 answer
149 views

Different deployment items for each test

I have different tests with different deployment items, like this: [TestMethod] [DeploymentItem("item1.xml")] public void Test1(){...} [TestMethod] [DeploymentItem("item2.xml")] public void Test2(){....
Pomber's user avatar
  • 1,165
5 votes
3 answers
3k views

Running selenium against multiple browsers with MSTEST

Im using selenium and using mstest to drive it. My problem is i want my entire suite to run against 3 different browsers(IE,Firefox and chrome). What i can't figure out is how to data drive my test ...
Martin Mussmann's user avatar
5 votes
0 answers
1k views

MSTest /noisolation fails tests

If I use MSTest with the parameter /noisolation my tests fail, but without it they pass. If I run MSTest without the parameter for the first time a ms office configuration box appears and configures ...
user384470's user avatar
5 votes
0 answers
7k views

How to run MSUnit tests with MSBuild

I have a MSBuild script which looks similar to: <Project xmlns="http://schemas.microsoft.com/developer/msbuild/2003"> <Target Name="Build"> <MSBuild Projects="MyProject....
Jon Cahill's user avatar
  • 4,988
5 votes
2 answers
986 views

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 ...
VikasPushkar's user avatar
4 votes
2 answers
1k views

Strange error when trying to discover MSTest tests in Visual Studio (.NET Core 7): "TestRunDirectoryLabel"

I recently migrated a C# project from .NET Framework 4.8 to .NET Core 7. In the new version, MSTest is failing to discover any of my unit tests. When I check out the old framework branch the tests in ...
Brambo's user avatar
  • 41
4 votes
1 answer
235 views

What difference should I expect when running a unit test vs debugging a unit test in VS?

Background I have a ViewModel that I want to unit test using the built-in test framework from Visual Studio. public async Task RefreshEntries(string rootID) { _isCurrentlyFetchingEntries = true; ...
Arthur Attout's user avatar
4 votes
0 answers
2k views

dotnet test Runsettings arguments to exclude unit tests from code coverage

So I was able to supply runsettings and that worked dotnet test --filter "TestCategory != Ignore" --no-build --no-restore -v normal --collect "Code coverage" -s *.runsettingss ...
Ofek's user avatar
  • 325
4 votes
0 answers
168 views

Working Directory Different for Different Tests

My team and I are working on an application that is stored in BitBucket with Visual Studio 2015 being our primary IDE. Our application's unit tests fail when the DataSource attribute is used, but pass ...
Steve H.'s user avatar
  • 3,313

1
2 3 4 5
22