3,690 questions
-1
votes
2
answers
73
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
1
answer
50
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.
...
2
votes
1
answer
92
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
72
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 ...
2
votes
1
answer
97
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:...
-1
votes
1
answer
64
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?
1
vote
1
answer
167
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
vote
1
answer
99
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 ...
0
votes
1
answer
157
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 ...
5
votes
1
answer
651
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 ...
0
votes
0
answers
72
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
603
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
0
answers
89
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
103
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
0
answers
49
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
...
0
votes
1
answer
125
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 ...
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 ...
2
votes
1
answer
69
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
1
answer
307
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-...
0
votes
1
answer
157
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 ...
1
vote
0
answers
268
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 ...
2
votes
2
answers
279
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
1
answer
60
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
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 ...
0
votes
0
answers
49
views
Run MSTest programmatically
I have an existing library containing unit tests. I want to transform that library into a service that periodically runs the unit tests and emit metrics. I solved the bits to create a service and to ...