Questions tagged [visualstudio.testtools]
14 questions
9
votes
2 answers
Visual Studio Unit tests: run initialization code before each test
I'm using Visual Studio's Test Tools for unit testing. I need some initialization code to run before each test.
I have a Setup class for the initialization code. I already added code to run before each test run, using [AssemblyInitialize], but I…

fikkatra
- 5,605
- 4
- 40
- 66
3
votes
1 answer
Assert.ThrowsException test fails when it does throw exception
I'm using Microsoft.VisualStudio.TestTools.UnitTesting for unit testing.
I have this test which asserts that an exception was thrown and it is failing
[TestMethod]
public async Task ShouldThrowHttpExceptionIfPassedObjectIsNull()
{
_mockLogger =…

BeniaminoBaggins
- 11,202
- 41
- 152
- 287
3
votes
0 answers
Why doesn't CollectionAssert provide any failure details?
When I write the following code in a C# unit test:
using Microsoft.VisualStudio.TestTools.UnitTesting;
CollectionAssert.AreEqual(new List { 1, 2, 3 }, new List { 1, 2 });
The unit test fails with the following details:
Fehler bei…

Roland Illig
- 40,703
- 10
- 88
- 121
1
vote
1 answer
C# Testing - Is [ClassInitialize] guaranteed to run only after previous tests are finished?
I'm using [ClassInitialize] and [ClassCleanup] tags from Microsoft.VisualStudio.TestTools.UnitTesting. MSTest 2.0
I have a test class with tests that require my app to be in a different mode than usual.
I turn the mode on in [ClassInitialize] and…

Martin Schmidke
- 21
- 5
1
vote
2 answers
"The calling thread must be STA, because many UI components require this" exception during unit test
I have a class called OptionsWindow which inherits from Window which is for picking from options in a window. And a Dialog Class which deals with these dialogs. In my test, im trying to mock the choice picked from the dialog.
[TestMethod]
public…

an007
- 111
- 1
- 9
1
vote
1 answer
How can I unit test a 64-bit .NET 4.7 project?
I first got a BadImageFormatException in my test project and after some research it seemed that it was caused because the test project had a AnyCPU build, while the project I want to test had a 64-bit build. After changing my test project to 64 bit…

Friso
- 2,328
- 9
- 36
- 72
1
vote
1 answer
How to export visual studio load test results in .ltrar format?
I have end to end automation of my performance test execution. But maintenance is bit tricky?
I want to export the results in .ltrar format. Does anyone know if there is any automated ways to do that ?

Heaven Lalpuriya
- 21
- 6
0
votes
0 answers
Unit testing: check values of the local variables within the private static void methods
I have a C# application that uses a lot of
1 ) private
2 ) static
3) return type of void
methods which is difficult to unit test.
I can use Microsoft.VisualStudio.TestTools.UnitTesting.PrivateType objects, and then use the InvokeStatic to…

crazyTech
- 1,379
- 3
- 32
- 67
0
votes
1 answer
AutomationPeer.GetChildrenCore () only reports first child to VisualStudio.TestTools
I'm not able to override GetChildrenCore correctly. I use this for a Canvas to get information about it's children (Line, Rectangle).
The output correctly indicates the first child but misses the second. Even though the Canvas already contains…

Florian
- 465
- 5
- 17
0
votes
1 answer
Implementation of IValueProvider leads to UITestControlNotAvailableException
I'm struggling a bit with UI Automation for an WindowsStore app. I get an UITestControlNotAvailableException as soon as I implement IValueProvider. If I remove the implementation it…

Florian
- 465
- 5
- 17
0
votes
1 answer
ClassInitialize doesn't execute when trying to run test cases grouped by classes
I have a couple of TestClasses each having few TestMethods.Again I need to create data for each of these TestMethods, all of which is handles in a SuiteBase file which is inherited by each of the TestClasses. I need to create the data once for each…

Reema
- 969
- 1
- 10
- 17
0
votes
1 answer
Visual Build Pro 9 fails to build Unit Tests that use PrivateObject
I've recently switched from Visual Build Pro 8 to Visual Build Pro 9, and am having issues with building certain test projects. This appears to be related to various unit tests having to use the PrivateObject class in order to test private methods,…

jimbo
- 603
- 9
- 27
0
votes
2 answers
missing UnitTestFramework in visualstudio2017
I updated VisualStudio from 2015 to 2017.
When i try to launch UWP unit tests, it seems that Microsoft.VisualStudio.TestPlatform.UnitTestFramework does not exists (it gives me an error).
I tried with Microsoft.VisualStudio.TestTools.UnitTesting and…
user7819936
0
votes
0 answers
ASP.Net Looking for guidance how to unit test code for MVC action
apologized to post this question here but i am in problem suddenly because i need to write unit test code for action where i am not good.
i am bit familiar with asp.net mvc. before i never write unit test code for action rather i manually test the…

Thomas
- 33,544
- 126
- 357
- 626