When double clicking on a test in MS Test's test explorer, where does Visual Studio 2015 look for the test code? - visual-studio-2012

I'm in process of debugging some unit tests that worked in VS2013 and broke in VS2015. There are a number of threads I'm trying to pull debugging this when I came across an odd issue: When I double click on a test in the Test Explorer, VS2015 has trouble finding the test code. The error message that appears briefly is:
"Cannot open the following file: MyTestClass.cpp" (MyTestClass is a made up name -- but you get the drift).
This happens for passing and non-passing tests. The project that houses the test code is a VS2012 (v110) project. My question is, where is VS2015 looking for the test code when I double click on the test in Test Explorer? It seems like this could be a symptom of why these tests are failing and I'm unsure what VS2015 is doing here.
Some additional information: The test class in question (one example of a class that VS2015 is having trouble finding) resides in the same folder as the .vcxproj file. The output directory for the test project is $(SolutionDir)$(Platform)\$(Configuration)\ and the intermediate directory is $(Platform)\$(Configuration)\. I can open the test class .cpp from the solution explorer and view the code. If I right click on a test from the .cpp file directly and click 'Run Test', the tests output claims "No tests found to run". I can run the test by right clicking on it in the test explorer. These are CppUnit tests. This definitely smells like some sort of path issue, but everything seems to be in place, which brings me here. Also, these tests still pass and work in VS2013's IDE without any code or compiler changes.

Related

CodedUI Test: How to run from Web Portal (MS Test Manager's replacement)

Using the Test hub in the Web Portal why is the "Associated Automation" tab completely empty, greyed out and prevented from being used?
What do I need to do to enable all this and run a coded ui test? I have hand coded, Coded UI tests that are build and in dlls but need to run the tests in those dlls in my test suite.
For background, I can run the tests in the dlls using a batch file and have done so successfully but struggling to get started running them from my test plan! My Microsoft "Test Manager" has the same problem, all greyed out but as Test Manager is being deprecated I am less concerned about that.
EDIT:
Another way of viewing this problem is to ask why does the Automation Status not show the option "Automated"? See picture below ...
It is not possible per MSDN documentation.
In the visual studio development environment, try right clicking on a test in test explorer, clicking something such as "Associate to Test Case", then entering in the test case number and see if that works. I believe it is greyed out because there is no valid input options through the web right now.

MTM with (automated) CodedUITest test-cases developed in VS2013 issues

I have created a number of (standalone) automated test-cases captured using CodedUITest in Visual Studio 2013, to test webpages.
They work fine within Visual Studio, individually; and when several of them are put into a single project as a solution, to create a kind of playlist.
However, I'm trying to use Microsoft Test Manager as a 'front-end' - in order to be able to select which tests, create play-lists, decide how many times a specific test-case should be run etc, with the results stored.
TFS is being used to both store my (individual) test-cases, and, where I'd like to deposit the resultant output of pass/fail etc.
Trouble is, even though the test-automation part functions very well within Visual Studio, getting Microsoft Test Manager to function with what I have, and its associated environment is proving a COMPLETE NIGHTMARE.
My system is simple; I have a virtual machine setup with the testing environment which allows (within VS) for me to run these automated tests.
Why is this proving so difficult to work with MTM? It should be easy - I should simply be having to point MTM at the folder my test-cases are stored, and use its GUI to tell it what and how many tests I want to run.
Anyone else have a similar problem, or a similar setup?
All MS do is point me to (countless) pages which I've already read - for which the whole lot seems to be much deeper than it needs to be.
You cant just point MTM at a folder and tell it to run the tests as it would have no idea where to put the data. The results of each codedui running are associated with a corresponding test case in mtm.
You also need to have an automated build create the output (your assemblies) for you. Idealy everything goes together with your application. As your application changes, so will your tests.
You should add your CodedUI projects to the same solution that is used to build the application that you are testing. Then when the automated build for that application kicks off your code is picked up to. Both things, test and application, end up in a drop location. It is that drop location that MTM will use to find your test assemblies.
If, while you have the main solution open, you open/create a Test Case you can go to the automation tab in Visual Studio and associate one of your CodedUI tests with that Test Case. The test case will then show up as Automated in MTM.
Now that we have the versioned bits and know where to find them MTM needs somewhere to run them. If you open MTM and switch to the Lab center you can create a Standard environment to run your tests. This will automatically go install the agents required so you wikk need admin on those boxes.
Now that we have both versioned tests and an environment you can find the Test Case in MTM and see that it is "automated". If you right-click on it and say run you will get a box requesting an environment, and which version of the bits to go run. It will then go off and run those tests against that environment and feed the result back into the Test Case.
Does that help?
You'll need to setup Test controller and Test agent and associate you build with a Test Plan in MTM.In Test Lab you need to associate Test Agent to the Test Controller.
Once done you'll need to allow File & Printer sharing exception
And then you will have to add Test Controllers and Agents to Appropriate Groups.
Control Panel->All Control Panel Items->Administrative Tools->Computer
Management

How to see MSBuild output generated in project load time?

I've noticed that when Visual Studio 2012 loads/initializes projects (when opening a solution or when changing platforms/configurations), it may execute some MSBuild targets - those that are listed as InitialTargets (it doesn't always do that - sometimes it waits until you actually build it; I can't figure out when exactly, but that's a different question).
Anyway, these targets may generate some output in the form of MSBuild messages. If the targets were being run as part of a build, these messages would go to the output window of Visual Studio (and perhaps a log file). These "load-time targets", though, do not seem to send their output to the output window.
How can I see or log the output of MSBuild targets which execute outside of build time, and specifically in initialization time?
The best information source from the MSBuild team at Microsoft I could find is dated (2005), but may still be actual if no one could come up with fresher information:
The project load logger is used when projects are opened. It discards all messages logged while the project is opened, puts warnings in the error list, and displays any errors in a message box to the user. The errors displayed are quite detailed and useful in helping diagnose project file formatting issues.

Visual Studio 2013 Analyze Code Code Coverage TestInitialize database file exists

Please can any one advise me on an issue I am having? I am using Microsoft.VisualStudio.TestTools.UnitTesting in a C# project in Visual Studio 2013.
I have unit tests which spin up a new database instance in the TestInitialise method using a DbContextInitialiser which inherits from DropCreateDatabaseAlways
If I "Run All" tests then the tests pass fine. If I try to "Anaylize Code Coverage" for all tests, tests start to fail with error messages indicating the .mdf file already exists. It should drop and recreate the database for each test, however I assume the tests are run asynchronously so a file lock developes.
Please advise what is my best course of action. Thanks in advance.
Best regards,
Duane.

Output of Unit Tests running in VisualStudio

What I am trying to achieve is quite simple but I am probably missing something.
All I want is to INSTATNLY see my tests logging in the Console window, I have tried
Console.WriteLine(...)
I have tried
Trace.WriteLine(...)
I have tried
Trace.Listeners.Add(new TextWriterTraceListener(Console.Out));
Trace.WriteLine(...)
This all show the output only AFTER the test has finished (and not in the Output console but as the "test output"), what I want is to see those logging as they happen.
The way I am running the tests is using "Test-> Run-> All Tests" from the VS main menu.
The only way I can somewhat achieve what I want is by using
Debug.WriteLine(...)
But for this I have to run the tests in debug "Test -> Debug -> All Tests" and its kinda annoying...
Am I missing something?
There is no way to achieve this except the one which you already know. MSTest adapter keeps caching the trace output and once test finishes, it emits it in the test output window.
This is a useful ask and I will pass this request to the mstest product owner in visual studio team.

Resources