3,691 questions
0
votes
1
answer
92
views
MSTest not properly discovering DataTestMethods when adding new folder to project
When attempting to add additional folders to my MSTest project and creating test class files within them that have tests that use the DataTestMethod tag with DataRow. Test explorer improperly ...
Advice
0
votes
1
replies
36
views
How do I convert a trx file into html in azure test pipeline
So how do I convert a TRX file into html in azure test pipeline.
We have a selection of pipelines which run tests on a nightly basis. The tests are designed in Visual Studio with C#, Playwright, ...
-1
votes
2
answers
101
views
How to mock ILogger and invoke via callback Console.Writeline to have invocations in test explorer?
I need to have every invocation from the ILogger interface of a test,
but I mock the ILogger interface in the class that is going to be tested, so it won't write to console and therefore the ILogger ...
1
vote
2
answers
226
views
Visual Studio Code Coverage Reports Not Listing Or Highlighting All Tested Code
using Visual Studio 17.14.18
I'm asking Visual Studio to give me a code coverage report, which it does. But there are lots of methods being used by the completed / passing tests that are not included ...
1
vote
1
answer
61
views
For MSTest.Sdk. v3.8.0 and above logs from another thread not assiged to correct test method
We use MsTest for integration testing involving communication with hardware, and in our case, multiple threads are needed. We do not require any parallel text execution, so all tests run sequentially.
...
0
votes
0
answers
55
views
Test Coverage Report including foreign namespace MSTest.Analyzers
I am currently loosing it about the attempt to generate test coverage reports for a current Corpo project. This worked flawlessly quite some time and is now running wild.
The tests are done using ...
2
votes
1
answer
112
views
Visual Studio silently reverts mstest package versions
With
Microsoft Visual Studio Community 2022, Version 17.14.12
VisualStudio.17.Release/17.14.12+36408.4
Microsoft .NET Framework
Version 4.8.09032
and this simple mstest project content:
<Project ...
0
votes
1
answer
28
views
Can not instantiate proxy of class Could not find a constructor that would match given arguments
When mocking like this:
transmissionsRepository = new Mock<TransmissionsRepository>(transmissionsContext, httpContextAccessor.Object, transLogger.Object);
controller = new UtilityController(...
0
votes
1
answer
98
views
Use MSTest.Sdk for TestHelper
I just ported all our test projects to MSTest.Sdk
But now I wonder how to deal with the TestHelperProject (This is a project providing Assert-Helpers, Config-Helper etc for the tests) so it is not a ...
0
votes
1
answer
117
views
System.ArrayTypeMismatchException when using System.Text.Json with .NET Framework 4.7 in MSTest
I'm currently using .NET Framework 4.7 along with MSTest (all packages are up to date). I'm trying to deserialize a JSON string using System.Text.Json as shown here:
using System.Text.Json;
private ...
2
votes
1
answer
102
views
TransactionScope lost on making TestInitialize async
For a project I'm working on, I'd like to insert testdata before every test and then rollback the transaction for the next test to start with a clean slate.
The skeleton code below works fine for that:...
0
votes
1
answer
84
views
How to isolate C# unit tests with global resources
Each unit test is supposed to be self contained, but unless we had some way of killing the entire process for each test, there is no way in .NET to guarantee another test hasn't done anything that ...
-1
votes
1
answer
69
views
How to clean up for each TestMethod in unit test MSTest?
The method marked with [TestCleanup] will be run after test methods marked the [TestMethod]. But I want to run different clean-up logic for each test methods. How to do that?
0
votes
1
answer
63
views
How do I write Visual Studio testlog during Azure Pipeline and save as a artifact
So we have numerous pipelines that run Selenium or Playwright tests overnight.
The test suites are built using C# with selenium or Playwright and MsTest.
The end result does not display the actual ...
1
vote
1
answer
181
views
testhost.exe doesn't see Microsoft.Android Framework?
I'm upgrading a Xamarin Forms project to MAUI taking the projects to .NET 8 and everything seems to be working alright until I try and run tests. The app works and all of my tests show in the Test ...
-1
votes
1
answer
92
views
How to Prevent A Project In Visual Studio From Building When Triggered a Unit Test Run For A Specific Build Configuration?
I have a project that checks for a particular solution build Configuration (DevDeploy) to deploy itself to a dev server:
I don't want that project to build and therefore prevent running a dev ...
1
vote
1
answer
104
views
F# testing using mstest cannot resolve method overload
As a learning exercise, I'm trying to test some F# code using MSTEST. I've run into a problem that is driving me crazy, not because I can't work around it, but because I don't understand how to ...
2
votes
1
answer
46
views
MSTest DynamicData - IEnumerable<object[]> current iteration
Issue
Is there a way when using MSTest that has a class decorated with DynamicData to get the current iteration.
Example:
// Some static file
public static IEnumerable<object[]> TheData()
{
...
0
votes
1
answer
173
views
MSTest parallel execution: Tests run in alphabetical order in Visual Studio but not in Azure DevOps pipeline
I'm using MSTest with parallel execution at the class level in my .runsettings file. Some test classes handle web tests, while others perform the same operations without web tests.
The Issue
In ...
1
vote
1
answer
83
views
DynamicData doesn't populate correctly test data when using grpc objects
I use Visual Studio 2022 and MS Test. To generate code from proto file I use Grpc.Tools (2.69.0) and Google.Protobuf (3.29.3) nugets.
I don't know how DynamicData feature works under the hood, but it ...
5
votes
1
answer
685
views
Tests with DataRow-attribute not executed with new mstest & sdk-package
I am using Visual Studion 17.12.5 and I am experiencing the following problem.
After upgrading the MSTest-package from 3.7.3 to 3.8.0 and Microsoft.NET.Test.Sdk from 17.12.0 to 17.13.0 the most of my ...
2
votes
1
answer
1k
views
Specflow to Reqnroll conversion scenario outline question
With the demise of Specflow we have completed a test conversion of one of our test projects to Reqnroll.
All appears to be working very well with 1 annoying situation involving Scenario Outline's
They ...
0
votes
0
answers
78
views
Verifying multiple POST payloads in a unit test
I have a unit test that currently posts an array of order lines to a third party vendor. They have requested that I change the code to send each order line as a single JSON payload. Making the code ...
0
votes
1
answer
63
views
Smartest way to unit test if IEquatable was implemented correctly if a class has many properties
Let's say I have a class ComponentDefinitionRoot which implements the IEquatable interface:
class ComponentDefinitionRoot: IEquatable<ComponentDefinitionRoot>
{
public string Id {get; set;}
...
0
votes
1
answer
638
views
System.Text.Json throws TypeInitializationException in .NET framework unit tests
I have created a (fresh) solution in Visual Studio 2022 17.12.4 with the following projects:
ClassLibrary1 (.NET framework 4.8)
Has System.Text.Json installed version 9.0.1
Has a static method Just....
0
votes
1
answer
79
views
I have a c# mstest unit test that runs fine locally, but fails on the build server. How can I get it to work on build server? (It uses async method)
I have the following unit test which runs fine locally (simplified and anonymised):
[TestMethod]
public void GotoPageCommand_Calls_PCCollection_SearchPage()
{
var page = 100;
var sut = CreateSut();...
0
votes
0
answers
95
views
Implementing Proper Canceling of a Bidirectional C# gRPC Endpoint That Returns a Response Stream
I'm struggling to get this bidirectional stream gRPC endpoint to work in unit tests with canceling an application's startup.
I've tried googling and copilot all day yesterday and I'm going in circles. ...
0
votes
1
answer
62
views
How to make .NET Framework Test Adapter follow Binding Redirects
I'm working with a custom test adapter being used in MSTest + dotnet test + Visual Studio, and have come across many transitive dependencies clashing in versions (specifically System.Memory, System....
0
votes
1
answer
110
views
VerifyTests: ‘TestContext' is a type, which is not valid in the given context
We recently started to use VerifyTests/Verify on Mstest .Net 8. Projects.
One of my colleagues has an error on local build:
CS0119 'TestContext' is a type, which is not valid in the given
context
...
0
votes
1
answer
153
views
"Microsoft.VisualStudio.TestPlatform.MSTest.TestAdapter.resources" not found when debugging tests in Rider
When I am debugging unit tests in Rider, I am getting a COMException:
System.Runtime.InteropServices.COMException (0x80070490): Element not found. (Exception from HRESULT: 0x80070490)
at Microsoft....
0
votes
0
answers
52
views
How to configure VSCode to unit test with MSTest?
I am trying to find the correct configuration steps for MSTest in VSCode.
Platform: Ubuntu
VSCode: 1.95.3
C# Dev Kit: 1.15.2 (pre)
I have two MSTest project below: Codificer.Testing & ToolKit
...
1
vote
0
answers
196
views
Updating MStest latest Build Error:- Constructor on type 'Microsoft.VisualStudio.TestPlatform.MSTest.TestAdapter.Execution.UnitTestRunner' not found
I am updating nuget packages for my solution so when updated
MSTest.TestAdapter.2.2.10 -> MSTest.TestAdapter.3.6.3
MSTest.TestFramework.2.2.10 -> MSTest.TestFramework.3.6.3
Locally things ...
0
votes
1
answer
135
views
Why do I get the error "Cannot access a disposed object" when using a stream
I am trying to read an xlsx file using CloseXlm so I created the below ReadFile method. In order to test it, I've created a test method using MSTest and another method that creates an xlsx file and ...
0
votes
1
answer
66
views
Unit test project is not finding extension methods
using Microsoft.VisualStudio.TestTools.UnitTesting;
using System;
namespace PdbLib
{
public static class AssertExtensions
{
public static void AssertVec3Equal(this Assert assert, Vec3 ...
1
vote
0
answers
23
views
MsTest Project: How do I include another UnitTest DLL and run all of its tests too?
TLDR: I have a unit test DLL file from another solution. I want to reference that dll and run its tests IN ADDITION TO the tests already in the current project / solution.
We have developed an app ...
1
vote
2
answers
128
views
Self-Cancelling Task Inhibits other Instances
I am trying to make a subclass of Task that cancels itself and waits when it is disposed.
While unit testing I got strange failing test cases. In the end it boiled down to repetition; I could even run ...
2
votes
1
answer
75
views
How to test the arguments of a Action that is itself passed as a method argument?
I'd first like to state that I'm new to StackOverflow, unit testing with NSubtitute and to working with actions/delegates in C# - so apologies in advance for any misuse of formatting and/or ...
0
votes
0
answers
48
views
COM Exception when running multiple MS tests
I am getting below COM Exception when running more than one test case at a time.
"Create an instance of a component with CLSID COM's {} from IClassFactory failed due to the following error: ...
0
votes
1
answer
314
views
ReSharper Test Runner Ignores `.runsettings` File, But Visual Studio Test Runner Works
I am facing an issue where the .runsettings file is not affecting the execution of my tests when I run them through the ReSharper test runner. However, when I run the tests using Visual Studio’s built-...
1
vote
2
answers
114
views
Ignoring thrown exceptions in an MSTest test
Suppose we wish to test the following method. It's a contrived network call that logs a warning if the request failed and then throws after three attempts.
private async Task<...
0
votes
1
answer
164
views
MSTest Not Discovering Test with [DataSource] Attribute for CSV File
I have an MSTest unit test that runs fine without the [DataSource] attribute. However, when I add a [DataSource] attribute to read from a CSV file, MSTest fails to discover the test. Here's the test ...
0
votes
1
answer
163
views
How can I access TestContext from within an TestMethodAttribute
I am trying to write a custom TestMethodAttribute that allows to annotate a test with some meta information that should be output in the .trx file generated by the test runner of MSTest.
I therefore ...
1
vote
0
answers
272
views
How to use MSTest to test a C# async method where it doesn't complete until I feed it more data?
I'm writing unit tests where the SUT is a queue; the language is C#, and I'm using the MSTest framework. One method in the queue, async Task<int[]> DequeueAsync(int count), waits until the ...
0
votes
1
answer
180
views
System.IO.FileNotFOundException for assembly that lives in the folder for my unit test project?
I am building a project for Revit and now want to build unit tests for my C# code. The issue I am running into is that whenever I actually build the project and reference my project I get an error ...
2
votes
2
answers
298
views
Unit testing async void (fire-and-forget) methods
I am writing tests in MSTest for a WPF application that contains calls to async void methods (fire-and-forget pattern).
My goal is to run this code synchronously during tests.
Is this possible?
I have ...
0
votes
0
answers
163
views
Unit Test for Azure Function HttpRequest parameter not detecting System.NotSupportedException
Background
I'm using MSTest and NSubstitute to build unit tests against some Azure Functions. These are .net 8, running in isolated mode. I'm working in VS2022 and using Test Explorer to run the tests....
0
votes
1
answer
72
views
Record Creation Test Case and Create Test Data Approach
I am quite new to Selenium and MSTEST. I have been able to run some test cases but struggling to organize things. I have a scenario where I have a test case which tests the creation of an Account ...
0
votes
1
answer
277
views
Can a Visual Studio Test task in ADO have both .net framework and modern .Net (e.g .net 6.0) tests run in the same task
I'm trying to get MSTest unit tests updated from .Net 4.7.2 to .Net 6.0 for 2 large solutions and have picked on a single test project in each to convert first, leaving the remaining test projects in ...
0
votes
1
answer
36
views
System.Text.Json deserializing-serializing numbers gives slightly-off numbers for some .NET versions
I have a test where a json with a number is deserialized, then serialized, then both jsons (original an deserialized-serialized) are compared for string equality. The project is built for net8.0 and ...
1
vote
0
answers
37
views
Asserting Exception message with multi-language build servers
In my unit tests, I want to be able to validate the content message of the exception but since our build servers farm has clients in french and english, the message changes between runs and ends up ...